public IHttpActionResult Post([FromBody] dynamic body) { if (body.nome != null && body.categoria != null) { tarefas last = tmdb.tarefas.ToList().LastOrDefault(); tmdb.tarefas.Add(new tarefas { id = (last == null) ? 0 : last.id + 1, nome = (string)body.nome, categoria = (string)body.categoria, feito = false, userid = (int)body.userid }); tmdb.SaveChanges(); return(Ok()); } return(NotFound()); }
public IHttpActionResult Put(int id, [FromBody] dynamic body) { tarefas t = tmdb.tarefas.Find(id); if (body.nome != null) { t.nome = (string)body.nome; } if (body.categoria != null) { t.categoria = (string)body.categoria; } if (body.feito != null) { t.feito = (bool)body.feito; } tmdb.SaveChanges(); return(Ok()); }