public bool CreateInventoryItemCategory(InventoryItemCategoryCreate model) { var entity = new InventoryItemCategory() { InventoryItemCategoryId = model.InventoryItemCategoryId, CategoryName = model.CategoryName }; using (var ctx = new ApplicationDbContext()) { ctx.InventoryItemCategories.Add(entity); return(ctx.SaveChanges() == 1); } }
/// <summary> /// Create a new Inventory Item Category /// </summary> /// <param name="inventoryItemCategory"></param> /// <returns></returns> public IHttpActionResult Post(InventoryItemCategoryCreate inventoryItemCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateInventoryItemCategoryService(); if (!service.CreateInventoryItemCategory(inventoryItemCategory)) { return(InternalServerError()); } return(Ok()); }