Hi,
I wrote a WCF Rest service to consume some service contracts from Xamarin Forms application.
I used Repository design pattern and unit of work for database transactions in DAL.
Then I wrote a class MobileResult to collectivize my returned objects.
But somehow it doesn't work.
Can you help me with this issue.
Thanks.
What I have tried:
I wrote a Operation Contract like this;
[OperationContract]
[WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "GetWorkCommandsInProduction")]
MobileResult GetAllWorkCommandsInProduction();
I wrote my MobileResult like this;
[DataContract]
public class MobileResult
{
[DataMember]
public bool result { get; set; }
[DataMember]
public object data { get; set; }
public MobileResult(bool res, object obj)
{
result = res;
data = obj;
}
}
And finally this is where I return MobileResult;
public MobileResult GetAllWorkCommandsInProduction()
{
UnitOfWork work = new UnitOfWork(new BILPLASDatabaseContext());
var products = work.Repository<WorkCommandProductions>().GetAll();
return new MobileResult(true, products);
}