Exemple #1
0
        /// <summary>
        /// Точка входа в программу
        /// </summary>
        /// <param name="args">Аргументы метода Main()</param>
        static void Main(string[] args)
        {
            CreateProducts create = new CreateProducts();
            /// Список с объектами типа Product для последующей работы
            List <Product> AllProduct = create.Fabric();

            Console.ReadKey();
        }
Exemple #2
0
 private Product ToDomainModel(CreateProducts model)
 {
     return(new Product
     {
         Id = model.Id,
         Amount = model.Amount,
         Name = model.Name,
         IsGroccery = model.IsGroccery
     });
 }
Exemple #3
0
        public async Task <IActionResult> Create([FromBody] CreateProducts Request)
        {
            try
            {
                if (Request == null)
                {
                    return(BadRequest(
                               new
                    {
                        error = "Your Request Cannot be Null"
                    }));
                }

                if (!ModelState.IsValid)
                {
                    return(BadRequest(new
                    {
                        error = "Your Model state is not valid"
                    }));
                }

                var model = ToDomainModel(Request);
                var exist = await productService.ProductExist(model.Id);

                if (!exist)
                {
                    var create = await productService.AddProductAsync(model);

                    if (!create)
                    {
                        return(BadRequest(new { error = "Unable to create Product" }));
                    }

                    var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
                    var locationUri = baseUrl + "/" + ApiRoutes.Products.Get.Replace("{Id}", model.Id.ToString());
                    var response    = ToOutputModel(model);

                    return(Created(locationUri, response));
                }
                else
                {
                    return(Ok("Product already exist"));
                }
            }
            catch (Exception ex)
            {
                logger.LogError(ex.Message + ":" + ex.StackTrace);
                throw;
            }
        }
Exemple #4
0
        static void Main(string[] args)
        {
            CreateFarmers     createFarmers = new CreateFarmers();
            List <Dto_Farmer> Farmers       = createFarmers.CreateFarmer();

            CreateProducts     createProducts = new CreateProducts();
            List <Dto_Product> Products       = createProducts.CreateProduct();

            CreateCropsFarmers createCropsFarmers = new CreateCropsFarmers();
            List <Dto_Crop>    Crops = createCropsFarmers.CreateCropFarmer(Products, Farmers);

            BusinessLogicTheFarmersCompany.PaymentValueToCapitalists(Crops, Farmers);
            BusinessLogicTheFarmersCompany.PaymentValueToFarmers(Crops);
            BusinessLogicTheFarmersCompany.LowestPriceSell(Crops);
        }
Exemple #5
0
        static void Main(string[] args)
        {
            CreateSellers     createSellers = new CreateSellers();
            List <Dto_Seller> sellers       = createSellers.CreateSeller();

            CreateProducts     createProducts = new CreateProducts();
            List <Dto_Product> products       = createProducts.CreateProduct();

            CreateSales     createSales = new CreateSales();
            List <Dto_Sale> sales       = createSales.CreateSale(sellers, products);

            BusinessLogicTheSalesSystem.SaleOfTheCheapestProduct(sales);
            BusinessLogicTheSalesSystem.ProductsPriceAverage(products);
            BusinessLogicTheSalesSystem.NumberOfUnitsSold(sales);
            BusinessLogicTheSalesSystem.CheapestProduct(products);
        }
Exemple #6
0
        static void Main(string[] args)
        {
            //Creación de Lista de clients
            CreateClients     createClients = new CreateClients();
            List <Dto_Client> clients       = createClients.CreateClient();

            //Creación de lista de sellers
            CreateSellers     createSellers = new CreateSellers();
            List <Dto_Seller> sellers       = createSellers.CreateSeller();

            //Creación de Lista de products
            CreateProducts     createProducts = new CreateProducts();
            List <Dto_Product> products       = createProducts.CreateProduct();

            //Creación de Lista de sales
            CreateSales     createSales = new CreateSales();
            List <Dto_Sale> sales       = createSales.CreateSale(clients, sellers, products);

            //Creación de Nodos de clients
            Dao_ClientNode dao_ClientNode = new Dao_ClientNode();
            Dto_ClientNode clientsNode    = dao_ClientNode.CreateClientsNodes(clients);

            //Creación de Nodos de sellers
            Dao_SellerNode dao_SellerNode = new Dao_SellerNode();
            Dto_SellerNode sellersNode    = dao_SellerNode.CreateSellersNodes(sellers);

            //Creación de Nodos de products
            Dao_ProductNode dao_ProductNode = new Dao_ProductNode();
            Dto_ProductNode productsNode    = dao_ProductNode.CreateProductsNodes(products);

            //Creación de Nodos de sales
            Dao_SaleNode dao_SaleNode = new Dao_SaleNode();
            Dto_SaleNode salesNode    = dao_SaleNode.CreateSalesNodes(sales);

            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();

            //Console.WriteLine("---- Punto 1: Importe total de ventas ----");
            //logicStoreSystem.TotalAmountSales(salesNode);

            //Console.WriteLine("\n---- Punto 2: Nombre del cliente que ha realizado la compra más importante ----");
            //logicStoreSystem.SaleMoreImportant(salesNode);

            //Console.WriteLine("\n---- Punto 3: Producto que está obteniendo más ventas ----");
            //logicStoreSystem.BestSellingProduct(salesNode);

            //Console.WriteLine("\n---- Punto 4: Promedio de ventas ----");
            //logicStoreSystem.SalesAverage(salesNode);

            //Console.WriteLine("\n---- Punto 5: Stock de productos: Informar existencias de cada producto ----");
            //logicStoreSystem.StockProducts(salesNode);

            //Console.WriteLine("\n---- Punto 6: Insertar y eliminar clientes ----");
            //logicStoreSystem.PrintClients(clientsNode);
            //clientsNode = logicStoreSystem.UpdateClients(clientsNode);
            //clientsNode = logicStoreSystem.returnPoint6(clientsNode);

            //Console.WriteLine("\n---- Punto 7: Insertar y eliminar productos ----");
            //logicStoreSystem.PrintProducts(productsNode);
            //productsNode = logicStoreSystem.UpdateProducts(productsNode);
            //productsNode = logicStoreSystem.returnPoint7(productsNode);

            //Console.WriteLine("\n---- Punto 8: Insertar y eliminar vendedores ----");
            //logicStoreSystem.PrintSellers(sellersNode);
            //sellersNode = logicStoreSystem.UpdateSellers(sellersNode);
            //sellersNode = logicStoreSystem.returnPoint8(sellersNode);

            Console.WriteLine("\n---- Punto 9: Crear nuevas ventas (se debe tener en cuenta la cantidad de productos) ----");
            Console.WriteLine("");
            logicStoreSystem.PrintSales(salesNode);
            salesNode = logicStoreSystem.UpdateSales(salesNode, clientsNode, sellersNode, productsNode);
            salesNode = logicStoreSystem.returnPoint9(salesNode, clientsNode, sellersNode, productsNode);
        }