예제 #1
0
        public void AddInventory(Quickafe.DataAccess.Inventory inventory)
        {
            AssignInventoryOutNumbering(inventory);

            SetAuditFields(inventory);
            DataContext.Inventories.Add(inventory);
            DataContext.SaveChanges();
        }
예제 #2
0
        public void DeleteInventory(long id)
        {
            var entityDtl = GetInventoryDetail(id);

            DataContext.InventoryDetails.RemoveRange(entityDtl);
            Quickafe.DataAccess.Inventory entity = GetInventory(id);
            DataContext.Inventories.Remove(entity);
            DataContext.SaveChanges();
        }
예제 #3
0
        public void UpdateInventory(Quickafe.DataAccess.Inventory inventory)
        {
            SetAuditFields(inventory);
            var oldInventoryDetail = DataContext.InventoryDetails.Where(o => o.InventoryId == inventory.Id).ToList();

            DataContext.InventoryDetails.RemoveRange(oldInventoryDetail);
            foreach (InventoryDetail inventoryDetail in inventory.InventoryDetails)
            {
                DataContext.InventoryDetails.Add(inventoryDetail);
            }
            DataContext.SaveChanges();
        }
        public ActionResult Create(CreateEditViewModel model, FormCollection form)
        {
            var inventory           = new Quickafe.DataAccess.Inventory();
            var inventoryOutDetails = new List <Quickafe.DataAccess.InventoryDetail>();

            model.Id         = 0;
            model.LocationId = inventoryOutProvider.GetLocationId();
            mapper.Map(model, inventory);
            mapper.Map(InventoryOutDetailSessionWrapper.Detail, inventoryOutDetails);

            inventory.InventoryDetails.AddRange(inventoryOutDetails);
            inventoryOutProvider.AddInventory(inventory);

            return(RedirectToAction("Index"));
        }