示例#1
0
        public IHttpActionResult GetTargets(Guid projectId, Guid achievement)
        {
            var achievements = UnitOfWork.DataListsRepository.FindIncluding(AchievementDataListId, d => d.AllItems);
            var targets      = UnitOfWork.FormValuesRepository.AllIncludingNoTracking(fv => fv.FilledForm)
                               .Where(fv => fv.FilledForm.ProjectId == projectId && fv.MetricId == TargetAchievementIdMetricId)
                               .Where(fv => achievement == null || (fv.GuidValue == achievement && fv.BoolValue == true))
                               .Select(fv => fv.FilledForm)
                               .Distinct()
                               .ToList()
                               .Select(filledForm => TargetDTO.From(filledForm));

            return(Ok(targets));
        }
示例#2
0
        public IHttpActionResult GetTargets(Guid projectId)
        {
            var today = DateTime.Today;

            var targetsform = UnitOfWork.FilledFormsRepository
                              .AllIncludingNoTracking(f => f.FormValues)
                              .Where(t => t.ProjectId == projectId && t.FormTemplateId == TargetFormTemplateId)
                              .ToList();
            var targets = targetsform.Where(t => t.FormValues.FirstOrDefault(v => v.MetricId == TargetFormWeekDateMetricId).DateValue.Value.Date <= today.Date)
                          .Where(f => f.FormValues.FirstOrDefault(v => v.MetricId == TargetIsAchievedMetricId).GuidValue != IsAchievedDataListItemId)
                          .Select(filledForm => TargetDTO.From(filledForm));

            return(Ok(targets));
        }