public ActionResult Inventory() { var m = new _5Bites.Models.Store_.Inventory.ViewModel(); using (var db = new dbEntities()) { var ss = db.Stores.Include("Location"); foreach (var s in ss) { var sm = new Models.Store_.Inventory.StoreModel(); sm.Id = s.Id; sm.Name = s.Location.Name; foreach (var i in s.Location.Inventories) { var pm = new Models.Store_.Inventory.ProductModel(); pm.Description = i.Product.Name; pm.Price = i.Product.RetailPrice; pm.Quantity = i.Quantity; sm.Inventory.Add(pm); } m.Stores.Add(sm); } } return View(m); }
public ActionResult Inventory() { var m = new _5Bites.Models.Store_.Inventory.ViewModel(); using (var db = new dbEntities()) { var ss = db.Stores.Include("Location"); foreach (var s in ss) { var sm = new Models.Store_.Inventory.StoreModel(); sm.Id = s.Id; sm.Name = s.Location.Name; foreach (var i in s.Location.Inventories) { var pm = new Models.Store_.Inventory.ProductModel(); pm.Description = i.Product.Name; pm.Price = i.Product.RetailPrice; pm.Quantity = i.Quantity; sm.Inventory.Add(pm); } m.Stores.Add(sm); } } return(View(m)); }