Пример #1
0
        public List <ITableModel> GetAll()
        {
            using (var response = APIClientConfig.ApiClient.GetAsync("tables"))
            {
                response.Wait();

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

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

                    ISoldProductDataAccess soldProductData = Factory.InstanceSoldProductDataAccess();

                    foreach (ITableModel table in model)
                    {
                        table.SoldProducts = soldProductData.GetByTable(table.ID);
                    }

                    return(model);
                }
                else
                {
                    throw new Exception(response.Result.ReasonPhrase);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// It completes the payment for all products of the List
        /// </summary>
        public static void PaySoldProducts(List <ISoldProductModel> sold, ISoldProductDataAccess soldProductData, ISoldProductAccomplishedDataAccess soldProductAccomplishedData)
        {
            foreach (ISoldProductModel product in sold)
            {
                ISoldProductAccomplishedModel auxProduct = MappingObjects.SoldProductToSoldProductAccomplished(product);
                soldProductAccomplishedData.Create(auxProduct);
            }

            soldProductData.DeleteList(sold);
        }
Пример #3
0
        public ITableModel FindById(int id)
        {
            using (var response = APIClientConfig.ApiClient.GetAsync($"tables/{id}"))
            {
                response.Wait();

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

                    ITableModel            model           = readTask.Result;
                    ISoldProductDataAccess soldProductData = Factory.InstanceSoldProductDataAccess();

                    model.SoldProducts = soldProductData.GetByTable(id);

                    return(model);
                }
                else
                {
                    throw new Exception(response.Result.ReasonPhrase);
                }
            }
        }
Пример #4
0
        /// <summary>
        /// It completes the payment of selected items in a list based in indexes from variable "Paid"
        /// </summary>
        public static void PaySelectedSoldProducts(List <ISoldProductModel> fullList, int[] Paid, ISoldProductDataAccess soldProductData, ISoldProductAccomplishedDataAccess soldProductAccomplishedData)
        {
            List <ISoldProductModel> sold = Factory.InstanceISoldProductModelList();

            foreach (int item in Paid)
            {
                ISoldProductModel product = Factory.InstanceSoldProductModel();
                product = fullList[item];

                ISoldProductAccomplishedModel auxProduct = MappingObjects.SoldProductToSoldProductAccomplished(product);

                soldProductAccomplishedData.Create(auxProduct);
                sold.Add(product);
            }

            foreach (ISoldProductModel element in sold)
            {
                fullList.Remove(element);
            }

            soldProductData.DeleteList(sold);
        }