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