0
votes

I started up using the Azure Mobile App SDK to develop my Xamarin app. Started with TableControlle, but due to want to keep most business logic in API, ended up most services using REST concept. E.g. :

        [MyAuthorize(ActivityEnum.None, UserRole.Admin)]
    [HttpGet]
    [Route("GetOrderByUser")]
    public IHttpActionResult GetOrderByUser(int tenantID, string userID)
    {
        try
        {
            var Orders = db.Orders
                    .Where(x => x.TenantID == tenantID && x.DateEndShip == null && x.DateCancel == null)
                    .Project().To<OrderDto>()
                    .ToList();

            foreach (var item in Orders)
            {
                item.CustomerName = db.Parties.FirstOrDefault(x => x.ID == item.CustomerID).Name;
                item.Order_Lines = db.Order_Line.Where(x => x.OrderID == item.OrderID)
                                    .Project()
                                    .To<Order_LineDto>()
                                    .ToList();
                foreach (var line in item.Order_Lines)
                {
                    line.ItemName = db.Items.FirstOrDefault(x => x.ID == line.ItemID).ItemID;
                }
            }

            return Ok(Orders);
        }
        catch (Exception ex)
        {
            return ResponseMessage(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
        }
    }

So used the HTTPClient in Xamarin. But this tend to be unstable and defeats the purpose hosting on Azure Mobile App service, I guess. Also, the authorization becomes messy, since I need to pass the token within the URL here.

Can I actually use Azure Mobile App SDK to call this service?

1

1 Answers

0
votes

The Azure Mobile Apps client SDK provides client access to an Azure Mobile Apps server SDK. You need to use the two in tandem. You cannot use one without using the other.

Since you are using Xamarin, check out the book at https://adrianhall.gitlab.io/develop-mobile-apps-with-csharp-and-azure/ - a lot of the concepts here are covered in the book.