public IActionResult PutTaskStatus(int key, [FromBody] Models.Crm.TaskStatus newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.Id != key)) { return(BadRequest()); } this.OnTaskStatusUpdated(newItem); this.context.TaskStatuses.Update(newItem); this.context.SaveChanges(); return(new NoContentResult()); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult Post([FromBody] Models.Crm.TaskStatus item) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (item == null) { return(BadRequest()); } this.OnTaskStatusCreated(item); this.context.TaskStatuses.Add(item); this.context.SaveChanges(); return(Created($"odata/Crm/TaskStatuses/{item.Id}", item)); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
public IActionResult PutTaskStatus(int?key, [FromBody] Models.Crm.TaskStatus newItem) { try { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (newItem == null || (newItem.Id != key)) { return(BadRequest()); } this.OnTaskStatusUpdated(newItem); this.context.TaskStatuses.Update(newItem); this.context.SaveChanges(); var itemToReturn = this.context.TaskStatuses.Where(i => i.Id == key); return(new ObjectResult(SingleResult.Create(itemToReturn))); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(BadRequest(ModelState)); } }
partial void OnTaskStatusUpdated(Models.Crm.TaskStatus item);
partial void OnTaskStatusDeleted(Models.Crm.TaskStatus item);