public IActionResult PutRole(int key, [FromBody] Models.CustomSecurity.Role newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.Id != key)) { return(BadRequest()); } this.OnRoleUpdated(newItem); this.context.Roles.Update(newItem); this.context.SaveChanges(); return(new NoContentResult()); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Post([FromBody] Models.CustomSecurity.Role item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnRoleCreated(item); this.context.Roles.Add(item); this.context.SaveChanges(); return(Created($"odata/CustomSecurity/Roles/{item.Id}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnRoleUpdated(Models.CustomSecurity.Role item);
partial void OnRoleDeleted(Models.CustomSecurity.Role item);