public IHttpActionResult PutTask(int id, Task task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != task.Id) { return(BadRequest()); } db.Entry(task).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!db.TaskExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult PostSeverityTask(Task task, SeverityTask severityTask) { if (!ModelState.IsValid || task.Id != severityTask.TaskId || db.TaskExists(task.Id)) { return(BadRequest(ModelState)); } db.Tasks.Add(task); db.SeverityTasks.Add(severityTask); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = severityTask.TaskId }, severityTask)); }