Example #1
0
        private async Task <AllObjectivesListViewModel> GetObjectiveModelForAllUsers()
        {
            ObjectiveUserViewModel GetModelFromUser(ApplicationUser user) => new ObjectiveUserViewModel(user?.UserId, user?.DisplayName, user?.Inactive);

            var users = _userRepository.GetAllUsers(includeInactive: true).ToDictionary(x => Guid.Parse(x.Id));

            var objectiveGroup = (await _objectivesRepository.GetAllObjectives()).GroupBy(x => x.UserId);

            return(new AllObjectivesListViewModel
            {
                UserObjectivesList = objectiveGroup.Select(objectives =>
                                                           new ObjectivesListByUserViewModel
                {
                    User = GetModelFromUser(users[objectives.Key]),
                    Objectives = objectives.Select(x => new ObjectiveListItemViewModel
                    {
                        Id = x.Id,
                        Title = x.Title,
                        KeyResults = x.KeyResults.Select(y => new KeyResultListItemViewModel {
                            Id = y.Id, Description = y.Description
                        }).ToList()
                    }).ToList()
                }).Where(x => x.User.Inactive == false)
                                     .OrderBy(x => x.User.Name)
                                     .ToList()
            });
        }
Example #2
0
        private async Task <Dictionary <string, Objective> > GetObjectiveLookup()
        {
            var dic        = new Dictionary <string, Objective>();
            var objectives = await _objectivesRepository.GetAllObjectives();

            foreach (var objective in objectives)
            {
                dic.TryAdd(objective.Title, objective);
            }
            return(dic);
        }