Esempio n. 1
0
        public ActionResult RsvpFinish()
        {
            var response = relyingParty.GetResponse();
            if (response == null)
            {
                return RedirectToAction("Index");
            }

            if (response.Status == AuthenticationStatus.Authenticated)
            {
                var id = Guid.Parse(response.GetUntrustedCallbackArgument("DinnerId"));
                var dinner = dinnerReadModel.GetDinnerById(id);

                // The alias we're getting here is NOT a secure identifier, but a friendly one,
                // which is all we need for this scenario.
                string alias = response.FriendlyIdentifierForDisplay;
                var sreg = response.GetExtension<ClaimsResponse>();
                if (sreg != null && sreg.MailAddress != null)
                {
                    alias = sreg.MailAddress.User;
                }

                // NOTE: The alias we've generated for this user isn't guaranteed to be unique.
                // Need to trim to 30 characters because that's the max for Attendee names.
                if (!dinner.IsUserRegistered(alias))
                {
                    var attendeeId = Guid.Parse(response.ClaimedIdentifier);

                    var rsvpForDinnerCommand = new RsvpForDinnerCommand { DinnerId = id, AttendeeName = alias, AttendeeId = attendeeId };
                    commandService.RsvpForDinner(rsvpForDinnerCommand);
                }
            }

            return RedirectToAction("Details", "Dinners", new { id = response.GetUntrustedCallbackArgument("DinnerId") });
        }
Esempio n. 2
0
        public ActionResult Register(Guid id)
        {
            var dinner = dinnerReadModel.GetDinnerById(id);

            if(!dinner.IsUserRegistered(User.Identity.Name))
            {
                var nerd = (NerdIdentity)User.Identity;
                var rsvpForDinnerCommand = new RsvpForDinnerCommand
                                               {DinnerId = id, AttendeeName = nerd.Name, AttendeeId = nerd.UserId};
                commandService.RsvpForDinner(rsvpForDinnerCommand);
            }

            return Content("Thanks - we'll see you there!");
        }
Esempio n. 3
0
        public ActionResult RsvpTwitterFinish(Guid id)
        {
            string screenName;
            int userId;
            if (TwitterConsumer.TryFinishSignInWithTwitter(out screenName, out userId))
            {
                var dinner = dinnerReadModel.GetDinnerById(id);

                // NOTE: The alias we've generated for this user isn't guaranteed to be unique.
                string alias = "@" + screenName;
                if (!dinner.IsUserRegistered(alias))
                {
                    var rsvpForDinnerCommand = new RsvpForDinnerCommand { DinnerId = id, AttendeeName = alias };
                    commandService.RsvpForDinner(rsvpForDinnerCommand);
                }
            }

            return RedirectToAction("Details", "Dinners", new { id });
        }
Esempio n. 4
0
 public void RsvpForDinner(RsvpForDinnerCommand rsvpForDinnerCommand)
 {
     commandBus.Execute(rsvpForDinnerCommand);
 }