示例#1
0
        public async Task <ServerResponseCollection <ApiModel.Product> > GetProducts()
        {
            var result = new ServerResponseCollection <ApiModel.Product>();

            try
            {
                var requestResult = await _productApi.GetProductsAsync(Settings.CurrentUser?.Name);

                var products = requestResult.Products.ToArray();
                foreach (var price in requestResult.Prices)
                {
                    products.First(x => x.Id == price.ProductId).Prices = price.Prices;
                }
                result.Data   = products;
                result.Status = Enums.ResponseStatus.Ok;
            }
            catch (NoInternetConnectionException)
            {
                result.Status  = Enums.ResponseStatus.NotConnected;
                result.Message = "No connection to the server";
            }
            catch (Exception ex)
            {
                result.Status  = Enums.ResponseStatus.Error;
                result.Message = ex.Message;
            }
            return(result);
        }