public IActionResult PutGender(int key, [FromBody] Models.ConData.Gender newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.GenderID != key)) { return(BadRequest()); } this.OnGenderUpdated(newItem); this.context.Genders.Update(newItem); this.context.SaveChanges(); var itemToReturn = this.context.Genders.Where(i => i.GenderID == key); this.OnAfterGenderUpdated(newItem); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Post([FromBody] Models.ConData.Gender item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnGenderCreated(item); this.context.Genders.Add(item); this.context.SaveChanges(); return(Created($"odata/ConData/Genders/{item.GenderID}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnAfterGenderUpdated(Models.ConData.Gender item);
partial void OnAfterGenderDeleted(Models.ConData.Gender item);
partial void OnGenderCreated(Models.ConData.Gender item);