public void Update(InventoriesModel inventory) { InventoryId = inventory.InventoryId; Name = inventory.Name; Description = inventory.Description; QuantityOnHand = inventory.QuantityOnHand; }
public ActionResult GetById(long?productId) { var inventorylist = new AllProducts(); if (productId != null) { var groupName = (GroupName)productId; var query = new InventoryQuery().GetInventories(groupName.ToString()); if (query != null) { foreach (var inventory in query) { var inverntoryModel = new InventoriesModel() { Id = inventory.Id, GroupName = groupName.ToString(), ItemsCount = inventory.ItemsCount, ProductName = inventory.ProductName }; inventorylist.InventoriesModels.Add(inverntoryModel); } } } return(PartialView("ProductsGrid", inventorylist)); }
public IHttpActionResult PostInventory(InventoriesModel inventory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var dbInventory = new Inventory(); _inventoryRepository.Add(dbInventory); _unitOfWork.Commit(); inventory.InventoryId = dbInventory.InventoryId; return(CreatedAtRoute("DefaultApi", new { id = inventory.InventoryId }, inventory)); }
public IHttpActionResult PutInventory(int id, InventoriesModel inventory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != inventory.InventoryId) { return(BadRequest()); } Inventory dbInventory = _inventoryRepository.GetById(id); dbInventory.Update(inventory); _inventoryRepository.Update(dbInventory); try { _unitOfWork.Commit(); } catch (Exception) { if (!InventoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public Inventory(InventoriesModel inventory) { this.Update(inventory); }