public Contracts.ControlCategory.ControlCategory Update(Contracts.ControlCategory.UpdateControlCategory updateControlCategory) { using (var db = new RAAPEntities(GetConnectionString())) { var ControlCategory = db.ControlCategories.FirstOrDefault(a => a.ControlCategoryId == updateControlCategory.ControlCategoryId); if (ControlCategory == null) { throw new RAAPNotFoundException("Item not found."); } ControlCategory.ApplyUpdate(updateControlCategory); db.SaveChanges(); return(ControlCategory.ToContract()); } }
public IHttpActionResult Put([FromBody] Contracts.ControlCategory.UpdateControlCategory update) { ControlCategoryService.Update(update); return(Ok()); }
public static void ApplyUpdate(this ControlCategory dataItem, Contracts.ControlCategory.UpdateControlCategory update) { dataItem.Name = update.Name; dataItem.Description = update.Description; dataItem.UpdatedOn = DateTime.Now; }