public ActionResult Index() { IEnumerable <UserTaskDTO> userTaskDTOs = userTaskService.GetUserTasks(); var userTasks = Mapper.Map <IEnumerable <UserTaskDTO>, List <UserTaskViewModel> >(userTaskDTOs); return(View("Index", userTasks)); }
public async Task <IActionResult> GetUserTasks(string id) { var usertasks = await _userTaskService.GetUserTasks(id); if (usertasks == null) { return(NotFound($"User with Id {id} does not have tasks.")); } return(Ok(usertasks)); }
public async Task <IEnumerable <UserTaskViewModel> > Get() { try { var userId = HttpContext.User.GetUserId(); var tasks = await _userTaskService.GetUserTasks(userId); return(tasks.Select(x => new UserTaskViewModel() { Id = x.Id, Description = x.Description, LastUpdate = x.LastUpdate })); } catch (Exception) { return(default);
public async Task <IEnumerable <TodoListDisplay> > Get() { int id = 0; int.TryParse(User.Identity.Name, out id); var todos = await _userTaskService.GetUserTasks(id); var displays = todos.Select(x => new TodoListDisplay() { Name = x.Name, Id = x.Id, Todos = x.Todos.Select(t => new TodoDisplay() { Id = t.Id, Title = t.Title, Completed = t.Completed, Position = t.Position }).OrderBy(t => t.Position).ToList() }).ToList(); return(displays); }
public ActionResult Create() { ViewBag.UserTaskId = new SelectList(userTaskService.GetUserTasks(), "UserTaskId", "UserTaskId"); return(View("Create")); }