public Contracts.ThreatCategory.ThreatCategory Update(Contracts.ThreatCategory.UpdateThreatCategory updateThreatCategory) { using (var db = new RAAPEntities(GetConnectionString())) { var threatCategory = db.ThreatCategories.FirstOrDefault(a => a.ThreatCategoryId == updateThreatCategory.ThreatCategoryId); if (threatCategory == null) { throw new RAAPNotFoundException("Item not found."); } threatCategory.ApplyUpdate(updateThreatCategory); db.SaveChanges(); return(threatCategory.ToContract()); } }
public IHttpActionResult Put([FromBody] Contracts.ThreatCategory.UpdateThreatCategory update) { ThreatCategoryService.Update(update); return(Ok()); }
public static void ApplyUpdate(this ThreatCategory dataItem, Contracts.ThreatCategory.UpdateThreatCategory update) { dataItem.Name = update.Name; dataItem.Description = update.Description; dataItem.UpdatedOn = DateTime.Now; }