public IHttpActionResult Posttodo_type(todo_type todo_type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.todo_type.Add(todo_type); try { db.SaveChanges(); } catch (DbUpdateException) { if (todo_typeExists(todo_type.todo_type_cd)) { return(Conflict()); } else { throw; } } return(CreatedAtRoute("DefaultApi", new { id = todo_type.todo_type_cd }, todo_type)); }
public IHttpActionResult Puttodo_type(int id, todo_type todo_type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != todo_type.todo_type_cd) { return(BadRequest()); } db.Entry(todo_type).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!todo_typeExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public IHttpActionResult Gettodo_type(int id) { todo_type todo_type = db.todo_type.Find(id); if (todo_type == null) { return(NotFound()); } return(Ok(todo_type)); }
public IHttpActionResult Deletetodo_type(int id) { todo_type todo_type = db.todo_type.Find(id); if (todo_type == null) { return(NotFound()); } db.todo_type.Remove(todo_type); db.SaveChanges(); return(Ok(todo_type)); }