public async Task <Result <GetEstimationStatisticsOutputModel> > Handle(GetEstimationStatisticsCommand request, CancellationToken cancellationToken) { var specification = new TaskEstimationByEstimatorSpecification(request.MemberId) .And(new TaskEstimationByProjectGroupSpecification(request.ProjectGroupId)) .And(new TaskEstimationByProjectSpecification(request.ProjectId)) .And(new TaskEstimationByCompletedTaskSpecification(true)); var estimations = await this._taskEstimationRepository.GetTaskEstimations(specification); var daysEstimatedVsActualDataSet = estimations.Select(e => new EstimationDataSetEntryOutputModel ( (e.EstimatedToFinishOn.Date - e.StartedOn.Date).Days, "Estimation (days)", (e.EstimatedToFinishOn.Date - e.StartedOn.Date).Days - (e.ActuallyFinishedOn.Date - e.StartedOn.Date).Days, "Difference estimation vs actual (days)" )) .ToList(); var result = new GetEstimationStatisticsOutputModel ( estimations.Count(), estimations.Count(e => (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days == 0), estimations.Count(e => (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days >= 1 && (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days <= 3), estimations.Count(e => (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days <= -1 && (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days >= -3), estimations.Count(e => (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days >= 3), estimations.Count(e => (e.ActuallyFinishedOn.Date - e.EstimatedToFinishOn.Date).Days <= -3), daysEstimatedVsActualDataSet ); return(Result <GetEstimationStatisticsOutputModel> .SuccessWith(result)); }
public async Task <Result <IEnumerable <GetTaskEstimationsOutputModel> > > Handle(GetTaskEstimationsCommand request, CancellationToken cancellationToken) { var specification = new TaskEstimationByEstimatorSpecification(request.MemberId) .And(new TaskEstimationByProjectGroupSpecification(request.ProjectGroupId)) .And(new TaskEstimationByProjectSpecification(request.ProjectId)) .And(new TaskEstimationByTaskSpecification(request.TaskId)) .And(new TaskEstimationByCompletedTaskSpecification(request.OnlyCompleted)); var estimations = await this._taskEstimationRepository.GetTaskEstimations(specification); return(Result <IEnumerable <GetTaskEstimationsOutputModel> > .SuccessWith(estimations)); }