public async Task <IHttpActionResult> Post([FromBody] MemberCategoryDtoModel category) { if (category == null) { return(BadRequest("Required data was not supplied.")); } if (await Exists(category.Description)) { return(Conflict()); } var record = Mapper.Map <MemberCategoryModel>(category); db.MemberCategories.Add(record); return(await SaveChanges(record, ActionType.Post)); }
public async Task <IHttpActionResult> Put(int id, [FromBody] MemberCategoryDtoModel category) { if (category == null) { return(BadRequest("Required data was not supplied.")); } if (!await Exists(id)) { return(NotFound()); } var record = await db.MemberCategories.FindAsync(id); if (category.Description != null && record.Description != category.Description) { record.Description = category.Description; } return(await SaveChanges(record, ActionType.Put)); }