public IHttpActionResult InsertTask(TaskViewModel task) { if (!ModelState.IsValid) { return(BadRequest()); } task.UserId = User.Identity.GetUserId(); try { taskService.AddOrUpdate(task.ProjectDto(mapper)); taskService.Save(); } catch (AutoMapperMappingException e) { Console.WriteLine(e); return(BadRequest(e.Message)); } 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)); }
public void AddOrUpdateTask([FromBody] PlanTaskDto taskForEdit) { _taskService.AddOrUpdate(taskForEdit); }
public TaskItem AddOrUpdate([FromBody] TaskItem taskItem) { return(_taskService.AddOrUpdate(taskItem)); }