/// <summary> /// HttpGet action that gets records from service layer and sends Index view to the client with a <see cref="DashboardViewModel"/> object. /// </summary> public async Task <IActionResult> Index() { /* * TODO : what to do when services return error? * */ string userId = User.FindFirstValue(ClaimTypes.NameIdentifier); var totalKanbanBoardsCountResult = await _kanbanBoardService.GetTotalKanbanBoardCountOfUserAsync(userId); int totalKanbanBoardCount = totalKanbanBoardsCountResult.Data; var lastEditedKanbanBoardResult = await _kanbanBoardService.GetLastEditedKanbanBoardOfUserAsync(userId); KanbanBoardDto lastEditedKanbanBoard = lastEditedKanbanBoardResult.Data; var totalNoteCountResult = await _noteService.GetTotalNoteCountOfUserAsync(userId); int totalNoteCount = totalNoteCountResult.Data; var lastEditedNoteResult = await _noteService.GetLastEditedNoteOfUserAsync(userId); NoteDto lastEditedNote = lastEditedNoteResult.Data; var completedToDoCountResult = await _toDoService.GetCompletedToDoCountOfUserAsync(userId); int completedToDoCount = completedToDoCountResult.Data; var incompleteToDoCountResult = await _toDoService.GetIncompleteToDoCountOfUserAsync(userId); int incompleteToDoCount = incompleteToDoCountResult.Data; var toDoesOfTodayResult = await _toDoService.GetToDoesOfUserOfTodayAsync(userId); List <ToDoDto> toDoesOfToday = toDoesOfTodayResult.Data.ToList(); DashboardViewModel dashboardViewModel = new DashboardViewModel { CompletedToDoCount = completedToDoCount, IncompleteToDoCount = incompleteToDoCount, ToDoesOfToday = toDoesOfToday, TotalKanbanBoardCount = totalKanbanBoardCount, LastEditedKanbanBoard = lastEditedKanbanBoard, TotalNoteCount = totalNoteCount, LastEditedNote = lastEditedNote }; return(View(dashboardViewModel)); }
/// <summary> /// Soft-deletes the kanban board record. /// </summary> public async Task <Result <KanbanBoardDto> > DeleteAsync(KanbanBoardDto kanbanBoardDto) { var result = await _kanbanCrudRepository.DeleteAsync(kanbanBoardDto); if (result.HasError) { return(new Result <KanbanBoardDto>() { Data = null, Errors = result.Errors }); } return(new Result <KanbanBoardDto>(result.Data)); }
public async Task <IActionResult> Add(KanbanBoardDto model) { if (ModelState.IsValid) { model.UserId = User.FindFirstValue(ClaimTypes.NameIdentifier); var result = await _kanbanService.AddAsync(model); if (result.HasError) { return(RedirectToError()); } else { return(RedirectToAction("Index", "KanbanBoard")); } } return(View(model)); }
/// <summary> /// Adds new kanban board and retrieves the newly created record. /// </summary> /// <param name="newKanbanDto">Data transfer object form of the <see cref="KanbanBoard"/> entity.</param> public async Task <Result <KanbanBoardDto> > AddAsync(KanbanBoardDto newKanbanDto) { return(await _kanbanCrudRepository.InsertAsync(newKanbanDto)); }