Ejemplo n.º 1
0
        // GET: Projects
        public async Task <IActionResult> MyDashboard()
        {
            var data = new MyDashboardViewModel();

            data.MyWorkItems = await _workItemDataService.GetActiveWorkItemsAsync();

            data.MyProjects = await _projectDataService.GetMyOpenProjects();

            return(View(data));
        }
Ejemplo n.º 2
0
        private async Task <MyDashboardViewModel> PrepareDashboardViewModel(ApplicationUser currentUser)
        {
            // get projects user created or the user is assigned to
            var myProjects = await _unitOfWork.Projects.GetProjectsForCurrentUser(currentUser);

            var myProjectsDto = _mapper.Map <IEnumerable <ProjectDetailsDto> >(myProjects);

            // get tickets user created or the user is assigned to
            var myTickets = await _unitOfWork.Tickets.GetTicketsForCurrentUser(currentUser);

            var myTicketsDto = _mapper.Map <IEnumerable <TicketBasicInfoDto> >(myTickets);

            // tickets due on this date
            var myTicketsDueToday = myTickets.Where(t => {
                var now    = DateTime.Now;
                var result = DateTime.Compare(now.Date, t.DueDate.Date);

                return(result == 0 && t.TicketStatusId != (int)EnumConstants.TicketStatuses.Closed); // get only tickets that are not closed (status 2)
            });
            var myTicketsDueTodayDto = _mapper.Map <IEnumerable <TicketBasicInfoDto> >(myTicketsDueToday);

            // overdue tickets
            var myOverdueTickets = myTickets.Where(t =>
            {
                var now    = DateTime.Now;
                var result = DateTime.Compare(now.Date, t.DueDate.Date);

                return(result > 0 && t.TicketStatus.Id != (int)EnumConstants.TicketStatuses.Closed);
            });
            var myOverdueTicketsDto = _mapper.Map <IEnumerable <TicketBasicInfoDto> >(myOverdueTickets);

            var myDashboardViewModel = new MyDashboardViewModel()
            {
                Id                = currentUser.Id,
                UserName          = currentUser.UserName,
                MyProjects        = myProjectsDto,
                MyTickets         = myTicketsDto,
                MyTicketsDueToday = myTicketsDueTodayDto,
                MyOverdueTickets  = myOverdueTicketsDto
            };

            return(myDashboardViewModel);
        }