예제 #1
0
        public async Task OnGetAsync()
        {
            string identityId = _signInManager.UserManager.GetUserId(User);
            var    userInfo   = await _userInformation.GetUserProfileInformationAsync(identityId);

            var ocp = await _userInformation.GetUserOccupationAsync(identityId);

            FillOccupationDropdown(ocp.Id);

            var aR = AgeRangeCalculator.GetAgeRange(userInfo.DateOfBirth.Value);

            AgeRange = AgeRangeCalculator.GetAgeRangeCaption(aR);
        }
예제 #2
0
        private async Task <CreateTeamDto> MapToDto(InputModel input)
        {
            string identityId = _signInManager.UserManager.GetUserId(User);
            var    userInfo   = await _userInformation.GetUserProfileInformationAsync(identityId);

            var aR = AgeRangeCalculator.GetAgeRange(userInfo.DateOfBirth.Value);

            return(new CreateTeamDto
            {
                Name = input.TeamName,
                OccupationFilter = input.OccupationFilter,
                Description = input.Description,
                OccupationIds = input.Occupations.Select(x => x.value).ToArray(),
                Range = aR,
                ProfileId = userInfo.ProfileId
            });
        }
예제 #3
0
        public async Task OnPostAsync()
        {
            string identityId = _signInManager.UserManager.GetUserId(User);
            var    userOcp    = await _userInformation.GetUserOccupationAsync(identityId);

            FillOccupationDropdown(userOcp.Id);
            var userInfo = await _userInformation.GetUserProfileInformationAsync(identityId);

            var aR = AgeRangeCalculator.GetAgeRange(userInfo.DateOfBirth.Value);

            AgeRange = AgeRangeCalculator.GetAgeRangeCaption(aR);

            if (ModelState.IsValid)
            {
                if (Input.OccupationFilter)
                {
                    if (!string.IsNullOrEmpty(Input.SelectedOccupations))
                    {
                        Input.Occupations =
                            JsonConvert.DeserializeObject <List <SelectedOccupation> >(Input.SelectedOccupations);
                    }

                    Input.Occupations.Add(new SelectedOccupation(userOcp.Name, userOcp.Id));

                    foreach (var ocp in Input.Occupations)
                    {
                        if (!await _ocpInformationService.AssertOccupationExists(ocp.value))
                        {
                            ModelState.AddModelError(string.Empty, $"Occupation {ocp.name} not found. Refine your selection.");
                            return;
                        }
                    }
                }

                var createTeamDto = await MapToDto(Input);

                _teamManager.TeamCreated    += PledgeMilesToCreatedTeam;
                _teamManager.CreationFailed += CreateTeamFailed;

                await _teamManager.CreateTeam(createTeamDto);
            }
        }