public static GeneralCIOViewModel GetGeneralCIOViewModel() { List <ApplicationUser> _users = db.Users.Where(m => m.BugNetUserId != null).ToList(); List <Project> _projects = db.Projects.ToList(); List <Issue> _issuesThisWeekAllProject = IssueRepositories.GetIssuesProjectIdFromDateToDate(_firstDayOfWeek, _lastDayOfWeek); List <Issue> _issuesLastWorkingDayTemp = IssueRepositories.GetIssuesEQDate(_lastWorkingDay).Where(m => m.IsClosed == true).ToList(); List <Issue> _issuesTodayTemp = IssueRepositories.GetIssuesEQDate(_today); List <Issue> _issuesNextWorkingDayTemp = IssueRepositories.GetIssuesEQDate(_nextWorkingDay); List <Issue> _issuesNotFinishedTemp = IssueRepositories.GetIssuesNotFinishedByDate(_today); List <Issue> _issuesFutureTemp = IssueRepositories.GetIssuesFutureByDate(_today); List <Issue> _issuesThisWeek = new List <Issue>(); List <Issue> _issuesLastWorkingDay = new List <Issue>(); List <Issue> _issuesToday = new List <Issue>(); List <Issue> _issuesNextWorkingDay = new List <Issue>(); List <Issue> _issuesNotFinished = new List <Issue>(); List <Issue> _issuesFuture = new List <Issue>(); foreach (var project in _projects) { _issuesThisWeek.AddRange(_issuesThisWeekAllProject.Where(m => m.ProjectId == project.Id).ToList()); _issuesLastWorkingDay.AddRange(_issuesLastWorkingDayTemp.Where(m => m.ProjectId == project.Id).ToList()); _issuesNextWorkingDay.AddRange(_issuesNextWorkingDayTemp.Where(m => m.ProjectId == project.Id).ToList()); _issuesToday.AddRange(_issuesTodayTemp.Where(m => m.ProjectId == project.Id).ToList()); _issuesNotFinished.AddRange(_issuesNotFinishedTemp.Where(m => m.ProjectId == project.Id).ToList()); _issuesFuture.AddRange(_issuesFutureTemp.Where(m => m.ProjectId == project.Id).ToList()); } GeneralCIOViewModel _generalCIO = new GeneralCIOViewModel(); _generalCIO.PerfomanceAverageToday = PerformanceHelpers.GetPerformanceAverageByIssues(_issuesToday, _users.Count); _generalCIO.PerfomanceAverageLastWorkingDay = PerformanceHelpers.GetPerformanceAverageByIssues(_issuesLastWorkingDay, _users.Count); _generalCIO.PerfomanceAverageNextWorkingDay = PerformanceHelpers.GetPerformanceAverageByIssues(_issuesNextWorkingDay, _users.Count); _generalCIO.PerfomanceAverageThisWeek = PerformanceHelpers.GetPerformanceAverageByIssuesInWeek(_issuesThisWeek, _users.Count); _generalCIO.PerformancesLastWorkingDate = PerformanceHelpers.GetPerformanceUserByIssuesDate(_issuesLastWorkingDay).OrderByDescending(m => m.y).ToList(); _generalCIO.PerformancesToday = PerformanceHelpers.GetPerformanceUserByIssuesDate(_issuesToday).OrderByDescending(m => m.y).ToList(); _generalCIO.PerformancesNextWorkingDate = PerformanceHelpers.GetPerformanceUserByIssuesDate(_issuesNextWorkingDay).OrderByDescending(m => m.y).ToList(); _generalCIO.IssuesNotFinished = IssueMappers.IssueToViewModels(_issuesNotFinished); _generalCIO.IssuesFuture = IssueMappers.IssueToViewModels(_issuesFuture); return(_generalCIO); }
public static StaffTimesViewModel GetPerformanceInDateViewModel(DateTime fromDate, DateTime toDate) { string user = "******"; List <Issue> _issuesInTimes = IssueRepositories.GetIssuesProjectIdFromDateToDate(fromDate, toDate); List <Project> _projects = db.Projects.ToList(); List <Issue> _issuesNotFinishedTemp = IssueRepositories.GetIssuesNotFinishedByDate(_today); List <Issue> _issuesFutureTemp = IssueRepositories.GetIssuesFutureByDate(_today); List <Issue> _issuesNotFinished = new List <Issue>(); List <Issue> _issuesFuture = new List <Issue>(); List <Issue> issuesInTimes = new List <Issue>(); foreach (var project in _projects) { issuesInTimes.AddRange(_issuesInTimes.Where(m => m.ProjectId == project.Id).ToList()); _issuesNotFinished.AddRange(_issuesNotFinishedTemp.Where(m => m.ProjectId == project.Id).ToList()); _issuesFuture.AddRange(_issuesFutureTemp.Where(m => m.ProjectId == project.Id).ToList()); } StaffTimesViewModel staffTimes = new StaffTimesViewModel(); List <GraphItem> issues = new List <GraphItem>(); staffTimes.FromDate = fromDate; staffTimes.ToDate = toDate; DateTime _dateTemp = staffTimes.FromDate; while (_dateTemp <= staffTimes.ToDate) { GraphItem _issue = new GraphItem(); _issue.x = _dateTemp.ToShortDateString(); _issue.y = PerformanceHelpers.GetPerformanceByIssues(issuesInTimes.Where(m => DateHelpers.IsEquals(m.IssueDueDate, _dateTemp) && m.AssignedUserName == user).ToList()); _dateTemp = _dateTemp.AddDays(1); issues.Add(_issue); } staffTimes.Performances = issues; staffTimes.UserName = user; staffTimes.IssuesNotFinished = IssueMappers.IssueToViewModels(_issuesNotFinished.Where(m => m.AssignedUserName == user).ToList()); staffTimes.IssuesFuture = IssueMappers.IssueToViewModels(_issuesFuture.Where(m => m.AssignedUserName == user).ToList()); staffTimes.IssuesAll = IssueMappers.IssueToViewModels(issuesInTimes.Where(m => m.AssignedUserName == user).ToList()); return(staffTimes); }