public async Task<IHttpActionResult> Create(TodoItemEditModel model) { if (!ModelState.IsValid) { return BadRequest(); } var todo = new TodoItem { Title = model.Title, IsDone = model.IsDone, IsPublic = model.IsPublic, AttendeeEmail = model.AttendeeEmail }; db.ToDoItems.Add(todo); await db.SaveChangesAsync(); return Ok(todo.Id); }
public async Task<IHttpActionResult> Edit(Guid id, TodoItemEditModel model) { if (!ModelState.IsValid) { return BadRequest(); } var todo = await db.ToDoItems.SingleOrDefaultAsync(x => x.Id == id); if (todo == null) { return NotFound(); } todo.Title = model.Title; todo.IsDone = model.IsDone; todo.IsPublic = model.IsPublic; todo.AttendeeEmail = model.AttendeeEmail; await db.SaveChangesAsync(); return Ok(); }