public IActionResult Put(int id, [FromBody] Tasc tasc) { var existing = context.TasksNou.AsNoTracking().FirstOrDefault(t => t.Id == id); if (existing == null) { context.TasksNou.Add(tasc); context.SaveChanges(); return(Ok(tasc)); } tasc.Id = id; //if (tasc.Stare.Equals(Tasc.State.Closed)) //{ // tasc.ClosedAt = DateTime.Now; //} //else //{ // tasc.ClosedAt = (DateTime?)null; //} context.TasksNou.Update(tasc); context.SaveChanges(); return(Ok(tasc)); }
public void Post([FromBody] Tasc tasc) { context.TasksNou.Add(tasc); context.SaveChanges(); }