public async Task <List <WorkDTO> > GetAllAsynk() { var result = await _workRepository.GetAll(); return(_mapper.Map <List <Work>, List <WorkDTO> >(result)); }
public IEnumerable <WorkItemViewModel> GetWorkItemsByFilter(FilterToWorkItem filter) { var result = _workRepository.GetAll().ToList(); if (!string.IsNullOrEmpty(filter.Search)) { result = result.Where(x => x.IssueId.Contains(filter.Search)).ToList(); } if (filter.Week != null) { var week = _mapper.Map <Week>(filter.Week); result = result.Where(x => x.WeekId == week.Id).ToList(); } if (filter.Epic != null) { var epic = _mapper.Map <Epic>(filter.Epic); result = result.Where(x => x.EpicId == epic.Id).ToList(); } if (filter.Type != null) { result = result.Where(x => x.Type == filter.Type).ToList(); } if (filter.Status != null) { result = result.Where(x => x.Status == filter.Status).ToList(); } if (filter.TechDebt != null) { result = result.Where(x => x.TechDebt == filter.TechDebt).ToList(); } if (filter.Assignee != null) { var assignee = _mapper.Map <Assignee>(filter.Assignee); result = result.Where(x => x.AssigneeId == assignee.Id).ToList(); } if (!string.IsNullOrWhiteSpace(filter.Team)) { result = result.Where(x => x.Team == filter.Team).ToList(); } result = result.Select(x => { if (x.AssigneeId.HasValue) { var assignee = _assigneeRepository.Find(x.AssigneeId.GetValueOrDefault()); x.SetAssignee(assignee); } var epic = _epicRepository.Find(x.EpicId); x.SetEpic(epic); return(x); }).ToList(); var workItems = _mapper.Map <IEnumerable <WorkItemViewModel> >(result); workItems = workItems.Select(x => { x.StatusDate = GetStatusDate(x); return(x); }).ToList(); return(workItems.OrderByDescending(x => x.UpdatedAt).ToList()); }
public IEnumerable <LearningObjectiveProgress> GetLearningObjectiveProgressReport(DateTime dateVal) { var dayWorkData = workRepo.GetAll().Where(o => o.SubmitDateTime.ToString("ddMMYYY") == dateVal.ToString("ddMMYYY")).ToList(); List <LearningObjectiveProgress> report = new List <LearningObjectiveProgress>(); var users = dayWorkData.Select(p => p.UserId).Distinct(); var query = from o in dayWorkData group o by o.LearningObjective into loGroups select new { LearningObjective = loGroups.Key, TotUser = loGroups.Distinct(), Participants = from cg in loGroups group cg by cg.UserId into cityGroups select new { Student = cityGroups.Key, Name = "Little ", Exercises = cityGroups.Select(s => s.ExerciseId).Distinct().Count(), Attempts = cityGroups.Select(s => s.SubmittedAnswerId).Distinct().Count() }, TotalExercise = from te in loGroups group te by te.ExerciseId into teGroups select new { TotalExercise = teGroups.Count() //PostCodes = cityGroups.Count() }, TotalAttempts = from ta in loGroups group ta by ta.SubmittedAnswerId into taGroups select new { TotalAttempts = taGroups.Count() //PostCodes = cityGroups.Count() } }; foreach (var item in query) { LearningObjectiveProgress rep = new LearningObjectiveProgress(); rep.LearningObjective = item.LearningObjective; rep.Participants = new List <Student>(); foreach (var std in item.Participants) { var s = new Student(); s.UserID = std.Student; s.Exercises = std.Exercises; s.Attempts = std.Attempts; s.Performance = ((std.Exercises / (double)std.Attempts)).ToString("0.00%"); rep.Participants.Add(s); } rep.TotalExercise = item.TotalExercise.Count(); rep.TotalAttempts = item.TotalAttempts.Count(); rep.MasteryPercentage = (int)(100 * rep.TotalExercise / (double)rep.TotalAttempts); if (rep.MasteryPercentage >= 75) { rep.Performance = "Excellent"; } else if (rep.MasteryPercentage >= 50 && rep.MasteryPercentage < 75) { rep.Performance = "Good"; } else { rep.Performance = "Poor"; } report.Add(rep); } return(report.ToList()); }