public async Task <IActionResult> PutTask(int id, dataLayer.Task task) { if (id != task.TaskId) { return(BadRequest()); } _context.Entry(task).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TaskExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <dataLayer.Task> > PostTask(dataLayer.Task task) { _context.Task.Add(task); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TaskExists(task.TaskId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetTask", new { id = task.TaskId }, task)); }