public IHttpActionResult UpdateTask(Todo.Models.Task task) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { taskService.AddOrUpdate(task); taskService.Save(); } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok(task)); }
public IHttpActionResult InsertTask(Todo.Models.Task task) { if (!ModelState.IsValid) { return(BadRequest()); } task.UserId = User.Identity.GetUserId(); task.DateAdded = DateTime.Now; try { taskService.AddOrUpdate(task); taskService.Save(); } catch (Exception e) { Console.WriteLine(e); throw; } return(Ok(task)); }