Esempio n. 1
0
 public ActionResult <IEnumerable <ToDoTask> > Get(int id)
 {
     try
     {
         return(Ok(_service.GetById(id)));
     }
     catch (System.Exception err)
     {
         return(BadRequest(err.Message));
     }
 }
        public async Task <JsonResult> SaveTodoTask(ToDoTask toDoTask)
        {
            if (toDoTask.ToDoTaskId == 0)
            {
                toDoTask.UserId = GetCurrentUser();
                toDoTask.IsDone = false;
                toDoTask.Status = Enums.Status.Active;
                var result = await _toDoTaskService.Add(toDoTask);

                return(Json(result));
            }
            else
            {
                var task = await _toDoTaskService.GetById(toDoTask.ToDoTaskId);

                task.Title = toDoTask.Title;
                var result = await _toDoTaskService.Save(task);

                return(Json(result));
            }
        }