public TaskDashboardViewModel(User user) { if (user == null) throw new ArgumentNullException("user"); var allTasks = user.LastVisitedJobSearch.Companies.SelectMany(x => x.Tasks).ToList(); OverdueTasks = allTasks.Where(x => (x.TaskDate.HasValue && x.TaskDate.Value.Date < DateTime.Today) || !x.TaskDate.HasValue) .Where(x => x.CompletionDate == null) .OrderBy(x => x.TaskDate) .ThenBy(x => x.Name) .ToList(); TodaysTasks = allTasks.Where(x => x.TaskDate.HasValue && x.TaskDate.Value.Date == DateTime.Today) .Where(x => x.CompletionDate == null) .OrderBy(x => x.Name) .ToList(); FutureTasks = allTasks.Where(x => x.TaskDate.HasValue && x.TaskDate.Value.Date > DateTime.Today) .Where(x => x.CompletionDate == null) .OrderBy(x => x.TaskDate) .ToList(); CurrentMilestone = user.LastVisitedJobSearch.CurrentMilestone; if (CurrentMilestone != null) MilestoneProgress = new JobSearchMilestoneProgress(user.LastVisitedJobSearch); }
/// <summary> /// Executes the command /// </summary> /// <param name="cmdParams"></param> public void Execute(StartNextJobSearchMilestoneCommandParams cmdParams) { // Retrieve the specified job search var search = _serviceFactory.GetService <JobSearchByIdQuery>().WithJobSearchId(cmdParams.JobSearchId).Execute(); if (search == null) { throw new MJLEntityNotFoundException(typeof(JobSearch), cmdParams.JobSearchId); } // If the job search has no current milestone, do nothing if (search.CurrentMilestoneId == null) { return; } // Determine if the current milestone has been completed var progress = new JobSearchMilestoneProgress(search); if (progress.TotalProgress == 1) { search.CurrentMilestone = search.CurrentMilestone.NextMilestone; if (search.CurrentMilestone == null) { search.MilestonesCompleted = true; } _serviceFactory.GetService <IUnitOfWork>().Commit(); } }
public void Milestone_Total_Progress_Is_Calculated_Correctly() { // Setup JobSearch search = new JobSearch { CurrentMilestone = new MilestoneConfig { JobSearchMetrics = new JobSearchMetrics { NumCompaniesCreated = 4, NumContactsCreated = 4 } }, Metrics = new JobSearchMetrics { NumCompaniesCreated = 3, NumContactsCreated = 2 } }; // Act JobSearchMilestoneProgress result = new JobSearchMilestoneProgress(search); // Verify Assert.AreEqual((decimal)0.625, result.TotalProgress, "Milestone's total progress value was incorrect"); }
public TaskDashboardViewModel(User user) { if (user == null) { throw new ArgumentNullException("user"); } var allTasks = user.LastVisitedJobSearch.Companies.SelectMany(x => x.Tasks).ToList(); OverdueTasks = allTasks.Where(x => (x.TaskDate.HasValue && x.TaskDate.Value.Date < DateTime.Today) || !x.TaskDate.HasValue) .Where(x => x.CompletionDate == null) .OrderBy(x => x.TaskDate) .ThenBy(x => x.Name) .ToList(); TodaysTasks = allTasks.Where(x => x.TaskDate.HasValue && x.TaskDate.Value.Date == DateTime.Today) .Where(x => x.CompletionDate == null) .OrderBy(x => x.Name) .ToList(); FutureTasks = allTasks.Where(x => x.TaskDate.HasValue && x.TaskDate.Value.Date > DateTime.Today) .Where(x => x.CompletionDate == null) .OrderBy(x => x.TaskDate) .ToList(); CurrentMilestone = user.LastVisitedJobSearch.CurrentMilestone; if (CurrentMilestone != null) { MilestoneProgress = new JobSearchMilestoneProgress(user.LastVisitedJobSearch); } }
public void Can_Calculate_NumContactsCreatedProgress() { // Setup MilestoneConfig milestone = new MilestoneConfig { JobSearchMetrics = new JobSearchMetrics { NumContactsCreated = 5 } }; JobSearch jobSearch = new JobSearch { Metrics = new JobSearchMetrics { NumContactsCreated = 2 }, CurrentMilestone = milestone }; // Execute JobSearchMilestoneProgress result = new JobSearchMilestoneProgress(jobSearch); // Verify Assert.AreEqual(((decimal)2 / (decimal)5), result.NumContactsCreatedProgress, "NumContactsCreatedProgress's value was incorrect"); }
public void Progress_Is_One_When_JobSearch_NumCompaniesCreated_Is_Greater_Than_Milestone() { // Setup MilestoneConfig milestone = new MilestoneConfig { JobSearchMetrics = new JobSearchMetrics { NumCompaniesCreated = 3 } }; JobSearch jobSearch = new JobSearch { Metrics = new JobSearchMetrics { NumCompaniesCreated = 4 }, CurrentMilestone = milestone }; // Execute JobSearchMilestoneProgress result = new JobSearchMilestoneProgress(jobSearch); // Verify Assert.AreEqual(1, result.NumCompaniesCreatedProgress, "NumCompaniesCreatedProgress's value was incorrect"); }
public void Milestone_Progress_Is_1_When_Milestone_Has_No_Metrics() { // Setup JobSearch search = new JobSearch { CurrentMilestone = new MilestoneConfig { JobSearchMetrics = new JobSearchMetrics() }, Metrics = new JobSearchMetrics() }; // Act JobSearchMilestoneProgress result = new JobSearchMilestoneProgress(search); // Verify Assert.AreEqual(1, result.TotalProgress, "Milestone's total progress value was incorrect"); }
/// <summary> /// Executes the command /// </summary> /// <param name="cmdParams"></param> public void Execute(StartNextJobSearchMilestoneCommandParams cmdParams) { // Retrieve the specified job search var search = _serviceFactory.GetService<JobSearchByIdQuery>().WithJobSearchId(cmdParams.JobSearchId).Execute(); if (search == null) throw new MJLEntityNotFoundException(typeof(JobSearch), cmdParams.JobSearchId); // If the job search has no current milestone, do nothing if (search.CurrentMilestoneId == null) return; // Determine if the current milestone has been completed var progress = new JobSearchMilestoneProgress(search); if (progress.TotalProgress == 1) { search.CurrentMilestone = search.CurrentMilestone.NextMilestone; if (search.CurrentMilestone == null) search.MilestonesCompleted = true; _serviceFactory.GetService<IUnitOfWork>().Commit(); } }
public void Progess_Is_One_When_Milestone_NumInPersonInterviewTasksCreated_Is_Zero() { // Setup MilestoneConfig milestone = new MilestoneConfig { JobSearchMetrics = new JobSearchMetrics { NumInPersonInterviewTasksCreated = 0 } }; JobSearch jobSearch = new JobSearch { Metrics = new JobSearchMetrics { NumInPersonInterviewTasksCreated = 2 }, CurrentMilestone = milestone }; // Execute JobSearchMilestoneProgress result = new JobSearchMilestoneProgress(jobSearch); // Verify Assert.AreEqual(1, result.NumInPersonInterviewTasksCreatedProgress, "NumInPersonInterviewTasksCreatedProgress's value was incorrect"); }