public IActionResult PutRole(string key, [FromBody] Models.Crm.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(); var itemToReturn = this.context.Roles.Where(i => i.Id == key); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Post([FromBody] Models.Crm.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/Crm/Roles/{item.Id}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnRoleUpdated(Models.Crm.Role item);
partial void OnRoleDeleted(Models.Crm.Role item);
partial void OnRoleCreated(Models.Crm.Role item);