コード例 #1
0
        // POST
        public Quotation CreateQuotation(Quotation quo)
        {
            // serialize
            counter += 1;

            if (String.IsNullOrEmpty(quo.CodClient) || String.IsNullOrEmpty(quo.CodProd) || quo.Quantity <= 0)
            {
                Console.Out.WriteLine("CodProd NULL o CodClient NULL o Cantidad <= 0 ");
                throw new Exception("CodProd NULL o CodClient NULL o Cantidad <= 0");
            }

            PricingBook    myBook      = _priceBookService.GetAllPrices().Result;
            List <Product> myPriceBook = myBook.Content;
            Product        precioProd  = myPriceBook.Find(pr => pr.ProductId == quo.CodProd);

            quo.Id = counter;
            //quo.Price = precioProd != null ? (precioProd.PromotionPrice != 0 ? precioProd.PromotionPrice : precioProd.Price) : 0;
            quo.Sale = false;

            _dbContext.AddQuotation(DTOMappers.MapGroupLD(quo));



            return(quo);
        }
コード例 #2
0
        // GET
        public List <Quotation> GetAllQuotations()
        {
            PricingBook    myBook      = _priceBookService.GetAllPrices().Result;
            List <Product> myPriceBook = myBook.Content;
            List <Data.Models.Quotation> quotations = _dbContext.GetAllQuotations();
            List <Quotation>             quots      = DTOMappers.MapQuotations(quotations);

            Console.Out.WriteLine("=================LISTA DE PRECIOS: ====================");
            foreach (var p in myPriceBook)
            {
                Console.WriteLine($"Precio CodProd: {p.ProductId} SetPrice: {p.FixedPrice} PromotionPrice: {p.PromotionPrice}");
            }

            Console.Out.WriteLine("==================LISTA DE COTIZACIONES===================");
            foreach (var qu in quots)
            {
                Product precioProd = myPriceBook.Find(pr => pr.ProductId == qu.CodProd);
                double  miPrecio   = 0;
                if (precioProd != null)
                {
                    if (precioProd.PromotionPrice == 0)
                    {
                        miPrecio = precioProd.FixedPrice;
                    }
                    else
                    {
                        miPrecio = precioProd.PromotionPrice;
                    }
                }
                else
                {
                    Console.WriteLine($"NO SE ENCONTRO EL CODIGO: {qu.CodProd}");
                }
                qu.Price = miPrecio;
                //qu.Price = miPrecio;
                Console.Out.WriteLine($"Id: {qu.Id} CodProd: {qu.CodProd} CodCliente: {qu.CodClient}" /*Price: {qu.Price}"*/);
            }


            return(quots);
        }