public IHttpActionResult Post(EntityToDo toDo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } toDo.CreateDate = DateTime.Now; repository.Add(toDo.ToDalToDoEntity()); return(StatusCode(HttpStatusCode.NoContent)); }
public static DalToDo ToDalToDoEntity(this EntityToDo task) { return(new DalToDo { Author = task.Author, Content = task.Content, Id = task.Id, Name = task.Name, CreateDate = task.CreateDate }); }
public IHttpActionResult Put(int id, EntityToDo toDo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != toDo.Id) { return(BadRequest()); } try { repository.Update(id, toDo.ToDalToDoEntity()); } catch { throw new Exception(); } return(StatusCode(HttpStatusCode.NoContent)); }