// 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); }
public List <Quotation> GetAllQuotations() { List <Data.Models.Quotation> quo = _dbContext.GetAllQuotations(); List <Price> myPriceBook = _priceBookService.GetAllPrices().Result; Console.Out.WriteLine("=================LISTA DE PRECIOS: ===================="); foreach (var p in myPriceBook) { Console.WriteLine($"Precio CodProd: {p.CodProd} SetPrice: {p.SetPrice} PromotionPrice: {p.PromotionPrice}"); } Console.Out.WriteLine("==================LISTA DE COTIZACIONES==================="); foreach (var prod in quo) { Price precioProd = myPriceBook.Find(pr => pr.CodProd == prod.CodProd); double miPrecio = 0; if (precioProd != null) { if (precioProd.PromotionPrice == 0) { miPrecio = precioProd.SetPrice; } else { miPrecio = precioProd.PromotionPrice; } } else { Console.WriteLine($"NO SE ENCONTRO EL CODIGO: {prod.CodProd}"); } prod.Price = miPrecio; Console.Out.WriteLine($"CodProd: {prod.CodProd} CodCliente: {prod.CodClient} Price: {prod.Price}"); } return(DTOMappers.MapQuotations(quo)); }