예제 #1
0
        public List <ISaleModel> GetSaleList()
        {
            List <ISaleModel> sales = Factory.InstanceISaleModelList();
            ISoldProductAccomplishedDataAccess   soldProductsAccomplishedData = Factory.InstanceSoldProductAccomplishedDataAccess();
            List <ISoldProductAccomplishedModel> products = soldProductsAccomplishedData.GetAll();

            foreach (ISoldProductAccomplishedModel product in products)
            {
                ISaleModel saleAux = Factory.InstanceSaleModel();

                saleAux = sales.Where(x => x.Name == product.Name && x.CategoryName == product.Category.Name).FirstOrDefault();

                if (saleAux == null)
                {
                    ISaleModel sale = Factory.InstanceSaleModel();

                    sale.Name         = product.Name;
                    sale.CategoryName = product.Category.Name;
                    sale.Price        = product.Price;
                    sale.Ammount      = 1;

                    sales.Add(sale);
                }
                else
                {
                    sales.Where(x => x.Name == product.Name && x.CategoryName == product.Category.Name).FirstOrDefault().Ammount++;
                    sales.Where(x => x.Name == product.Name && x.CategoryName == product.Category.Name).FirstOrDefault().Price += product.Price;
                }
            }

            return(sales);
        }
예제 #2
0
        public void EraseDataFromSaleList()
        {
            ISoldProductAccomplishedDataAccess   soldProductsAccomplishedData = Factory.InstanceSoldProductAccomplishedDataAccess();
            List <ISoldProductAccomplishedModel> products = soldProductsAccomplishedData.GetAll();

            foreach (var product in products)
            {
                soldProductsAccomplishedData.Delete(product.ID);
            }
        }
예제 #3
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);
        }
예제 #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);
        }