Example #1
0
        public List <ISoldProductAccomplishedModel> GetAll()
        {
            using (var response = APIClientConfig.ApiClient.GetAsync("soldproductsaccomplished"))
            {
                response.Wait();

                if (response.Result.IsSuccessStatusCode)
                {
                    var readTask = response.Result.Content.ReadAsAsync <List <SoldProductAccomplishedModel> >();
                    readTask.Wait();

                    List <ISoldProductAccomplishedModel> model = readTask.Result.ToList <ISoldProductAccomplishedModel>();

                    IDataAccessRegular <ICategoryModel> categoryData = Factory.InstanceCategoryDataAccess();

                    foreach (ISoldProductAccomplishedModel product in model)
                    {
                        product.Category = categoryData.FindById(product.CategoryID);
                    }

                    return(model);
                }
                else
                {
                    throw new Exception(response.Result.ReasonPhrase);
                }
            }
        }