Exemplo n.º 1
0
        public async Task <IActionResult> ManageReports()
        {
            var user = await _userManager.FindByNameAsync(User.Identity.Name);

            var reports          = _reportData.GetByAuthorId(user.Id);
            var reportViewModels = new List <ReportViewModel>();

            foreach (var report in reports)
            {
                reportViewModels.Add(new ReportViewModel {
                    Id          = report.Id,
                    ProjectName = report.Project.Title,
                    Date        = report.Date.ToHijri(),
                    Title       = report.Title,
                    IsViewed    = report.ProjectManagers.Any(pm => pm.IsViewd == true)
                });
            }

            var userReportViewModel = new UserReportViewModel {
                Reports  = reportViewModels,
                Messages = SystemOperations.GetMessageViewModels(_messageService, user.Id)
            };

            return(View(userReportViewModel));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> ManageReports(String nav)
        {
            var manager = await _userManager.FindByNameAsync(User.Identity.Name);

            var userReports = _reportData.GetAllReports(manager.Id);

            var userReportViewModels = new List <ReportViewModel>();

            foreach (var report in userReports)
            {
                userReportViewModels.Add(new ReportViewModel
                {
                    Id            = report.Report.Id,
                    Title         = report.Report.Title,
                    Author        = report.Report.Author,
                    Text          = report.Report.Text,
                    ProjectName   = report.Report.Project.Title,
                    TaskStartTime = report.Report.TaskStartTime,
                    TaskEndTime   = report.Report.TaskEndTime,
                    Date          = report.Report.Date.ToHijri(),
                    IsViewed      = report.IsViewd
                });
            }

            var reportsViewModel = new ReportsManagementViewModel
            {
                ManagerId   = manager.Id,
                UserReports = userReportViewModels,
                Messages    = SystemOperations.GetMessageViewModels(_messageService, manager.Id)
            };

            return(View(reportsViewModel));
        }
Exemplo n.º 3
0
        public IActionResult AdminPanel()
        {
            //prepare datas for chart
            short ADMIN_ID           = 1;
            var   projects           = _projectData.GetAll();
            var   today              = DateTime.Now;
            var   userReports        = _reportData.GetReportsOfLastSevenDays();
            var   managerReports     = _managerReportData.GetReportsOfLastSevenDays();
            var   userReportCount    = new List <int>();
            var   managerReportCount = new List <int>();
            var   projectViewModels  = new List <ProjectViewModel>();
            var   warnings           = _messageService.GetWarnings();
            var   warningViewModels  = new List <WarningViewModel>();
            var   activities         = _activityData.GetAllActivities().ToList();

            //A list for the last 7 days
            var days = new List <String>();

            //counting number of reports in the last 7 days
            for (int i = -6; i <= 0; i++)
            {
                var day = today.AddDays(i);               //finding the day that we want to count reports
                days.Add(day.ToHijri().GetDayAndMonth()); //Adding to days List
                userReportCount.Add(userReports.Count(r => r.Date.Date == day.Date));
                managerReportCount.Add(managerReports.Count(r => r.Date.Date == day.Date));
            }


            foreach (var project in projects)
            {
                projectViewModels.Add(new ProjectViewModel {
                    Id         = project.Id,
                    Title      = project.Title,
                    CreateDate = project.CreateDate.ToHijri().GetDate(),
                    EndDate    = project.EndDate.HasValue ? project.EndDate.Value.ToHijri().GetDate() : null
                });
            }
            foreach (var warning in warnings)
            {
                warningViewModels.Add(new WarningViewModel {
                    ReceiverName = String.Concat(warning.Receiver.FirstName, " ", warning.Receiver.LastName),
                    Title        = warning.Message.Title,
                    IsViewed     = warning.IsViewd,
                    ElapsedTime  = Math.Round(DateTime.Now.Subtract(warning.Message.Time).TotalHours)
                });
            }

            var adminPanelModel = new AdminPanelViewModel {
                Days                = days,
                Projects            = projectViewModels,
                UsersReportCount    = userReportCount,
                ManagersReportCount = managerReportCount,
                Warnings            = warningViewModels,
                Messages            = SystemOperations.GetMessageViewModels(_messageService, ADMIN_ID),
                Activities          = activities
            };

            return(View(adminPanelModel));
        }