private void FillProductsList(String id = "") { var list = pdb.Get_All(); Products = new List <ProductToOrder>(); foreach (var item in list) { item.Category = new MCategories().Get(item.Category_ID); item.Producer = new MProducers().Get(item.Producer_ID); Products.Add(new ProductToOrder(item)); } if (!String.IsNullOrEmpty(id)) { foreach (var item in db.GetOrders_Info(id)) { var oi = Products.Where(i => i.ID.CompareTo(item.Product_ID) == 0).FirstOrDefault(); if (oi != null) { oi.OrderQuantity = item.Quantity; oi.PurchasePrice = item.Price; } else { var up = new MProducers().GetUNProducer().ID; var uc = new MCategories().GetUNCategory().ID; Product product = new Product() { ID = item.Product_ID, Picture = "", Product_Name = "", Quantity = 0, Price = 0, Category_ID = up, Producer_ID = uc }; pdb.Add(product); Products.Add(new ProductToOrder(product, item.Price, item.Quantity)); } } } }
private List <Product> GetList(String ID) { var list = db.Get_All().Where(item => item.ID.Contains(ID)).ToList(); foreach (var item in list) { item.Category = MC.Get(item.Category_ID); item.Producer = MP.Get(item.Producer_ID); } return(list); }