public void ItSendsThePlayerInvitation()
        {
            PlayerInvitationViewModel playerInvitationViewModel = new PlayerInvitationViewModel
            {
                EmailAddress = "email address",
                EmailBody = "email body",
                EmailSubject = "email subject",
                PlayerId = 1
            };
            ApplicationUser applicationUser = new ApplicationUser();

            autoMocker.ClassUnderTest.Url.Expect(mock => mock.Action(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name))
                .Return("some url");

            autoMocker.ClassUnderTest.InvitePlayer(playerInvitationViewModel, applicationUser);

            autoMocker.Get<IPlayerInviter>().AssertWasCalled(mock => mock.InvitePlayer(Arg<PlayerInvitation>.Matches(
                invite => invite.CustomEmailMessage == playerInvitationViewModel.EmailBody
                && invite.EmailSubject == playerInvitationViewModel.EmailSubject
                && invite.InvitedPlayerEmail == playerInvitationViewModel.EmailAddress
                && invite.InvitedPlayerId == playerInvitationViewModel.PlayerId),
                Arg<ApplicationUser>.Is.Same(applicationUser)));
        }
Пример #2
0
        public virtual ActionResult InvitePlayer(PlayerInvitationViewModel playerInvitationViewModel, ApplicationUser currentUser)
        {
            var playerInvitation = new PlayerInvitation
            {
                InvitedPlayerId = playerInvitationViewModel.PlayerId,
                InvitedPlayerEmail = playerInvitationViewModel.EmailAddress.Trim(),
                EmailSubject = playerInvitationViewModel.EmailSubject,
                CustomEmailMessage = playerInvitationViewModel.EmailBody
            };

            playerInviter.InvitePlayer(playerInvitation, currentUser);

            SetToastMessage(TempMessageKeys.TEMP_MESSAGE_KEY_PLAYER_INVITED,$"Mail to invite {playerInvitationViewModel.PlayerName} sended succesfully");

            return new RedirectResult(Url.Action(MVC.GamingGroup.ActionNames.Index, MVC.GamingGroup.Name));
        }
Пример #3
0
        public virtual ActionResult InvitePlayer(int id, ApplicationUser currentUser)
        {
            PlayerDetails playerDetails;

            try
            {
                playerDetails = playerRetriever.GetPlayerDetails(id, 0);
            }
            catch (KeyNotFoundException)
            {
                return new HttpStatusCodeResult(HttpStatusCode.NotFound);
            }

            var emailSubject = string.Format(EMAIL_SUBJECT_PLAYER_INVITATION, currentUser.UserName);

            var playerInvitationViewModel = new PlayerInvitationViewModel
            {
                PlayerId = playerDetails.Id,
                PlayerName = playerDetails.Name,
                EmailSubject = emailSubject,
                EmailBody = EMAIL_BODY_PLAYER_INVITATION
            };
            return View(MVC.Player.Views.InvitePlayer, playerInvitationViewModel);
        }