예제 #1
0
        private async Task <Dictionary <string, ApplicationUser> > GetUsers(IEnumerable <string> emails, ApplicationUser currentUser, League league)
        {
            var result = new Dictionary <string, ApplicationUser>();

            foreach (var email in emails)
            {
                result[email] = await _invitesService.Invite(email, currentUser, league, Url);
            }

            return(result);
        }
예제 #2
0
        public async Task <IActionResult> Create(InviteViewModel invite)
        {
            var currentUser = await User.GetApplicationUser(_userManager);

            invite.Leagues = _leaguesRepository.GetLeagues(currentUser);

            if (!ModelState.IsValid)
            {
                return(View(invite));
            }

            League league = null;

            if (invite.LeagueId.HasValue)
            {
                league = _leaguesRepository.GetUserAuthorizedLeague(currentUser, invite.LeagueId.Value);

                if (league == null)
                {
                    ModelState.AddModelError("", _localizer[nameof(LocalizationKey.LeagueNotFound)]);
                    return(View(invite));
                }
            }

            try
            {
                await _invitesService.Invite(invite.Email, currentUser, league, Url);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(invite));
            }

            return(RedirectToAction("Index"));
        }