Esempio n. 1
0
        public ActionResult Purchase()
        {
            int EmployeeId = (int)Session.Contents["EmployeeId"];
            var m = new Models.Inventory_.Purchase.ViewModel();

            using (var db = new dbEntities())
            {
                var ps = db.Products;
                var ls = db.EmployeeLocations.Where(el => el.EmployeeId == EmployeeId).Select(el => el.Location);

                foreach (var l in ls)
                {
                    var lm = new Models.Inventory_.Purchase.LocationModel();
                    lm.Id = l.Id;
                    lm.Name = l.Name;
                    foreach (var p in ps)
                    {
                        var pm = new Models.Inventory_.Purchase.ProductModel();
                        pm.Id = p.Id;
                        pm.Name = p.Name;
                        pm.Price = p.WholesalePrice;
                        pm.OldQuantity = p.Inventories.SingleOrDefault(i => i.Location == l).Quantity;
                        lm.Inventory.Add(pm);
                    }
                    m.Locations.Add(lm);
                }
            }

            return View(m);
        }
Esempio n. 2
0
        public ActionResult Purchase()
        {
            int EmployeeId = (int)Session.Contents["EmployeeId"];
            var m          = new Models.Inventory_.Purchase.ViewModel();

            using (var db = new dbEntities())
            {
                var ps = db.Products;
                var ls = db.EmployeeLocations.Where(el => el.EmployeeId == EmployeeId).Select(el => el.Location);

                foreach (var l in ls)
                {
                    var lm = new Models.Inventory_.Purchase.LocationModel();
                    lm.Id   = l.Id;
                    lm.Name = l.Name;
                    foreach (var p in ps)
                    {
                        var pm = new Models.Inventory_.Purchase.ProductModel();
                        pm.Id          = p.Id;
                        pm.Name        = p.Name;
                        pm.Price       = p.WholesalePrice;
                        pm.OldQuantity = p.Inventories.SingleOrDefault(i => i.Location == l).Quantity;
                        lm.Inventory.Add(pm);
                    }
                    m.Locations.Add(lm);
                }
            }

            return(View(m));
        }