Ejemplo n.º 1
0
        public async Task <ActionResult> RSVP(WeddingGuestViewModel model)
        {
            if (ModelState.IsValid)
            {
                var guest = await _unitOfWork.WeddingGuestRepository.GetByIDAsync(model.Id);

                var oldResponse = new WeddingGuest();
                oldResponse.InjectFrom(guest);
                guest.InjectFrom(model);
                if (!guest.DidRsvp)
                {
                    guest.DidRsvp  = true;
                    guest.RsvpDate = DateTime.Now;
                }
                else
                {
                    guest.UpdatedRsvp     = true;
                    guest.UpdatedRsvpDate = DateTime.Now;
                    ViewBag.UpdatedRsvp   = true;
                }
                await _unitOfWork.SaveAsync();

                // send RSVP Confirmation email
                await SendRsvpEmailAsync(guest);

                // send Admin notification email
                if ((guest.UpdatedRsvp && guest.CanAttend == false) || (guest.UpdatedRsvp && guest.HasPlusOne && oldResponse.PlusOneCanAtend == true && guest.PlusOneCanAtend == false))
                {
                    await SendAdminRsvpNotificationAsync(guest, oldResponse);
                }

                return(RedirectToAction("RSVPConfirmation", new { userId = model.Id }));
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <ActionResult> RSVPConfirmation(string userId)
        {
            if (userId == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var guest = await UserManager.FindByIdAsync(userId) as WeddingGuest;

            if (guest == null)
            {
                return(HttpNotFound());
            }

            if (guest.UpdatedRsvp)
            {
                ViewBag.UpdatedRsvp = true;
            }

            var viewModel = new WeddingGuestViewModel();

            viewModel.InjectFrom(guest);

            return(View(viewModel));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> RSVP(string userId)
        {
            if (userId == null)
            {
                //return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
                var defaultGuest = await UserManager.FindByEmailAsync("*****@*****.**") as WeddingGuest;

                var defaultViewModel = new WeddingGuestViewModel();
                defaultViewModel.InjectFrom(defaultGuest);
                return(View(defaultViewModel));
            }

            var guest = await UserManager.FindByIdAsync(userId) as WeddingGuest;

            if (guest == null)
            {
                return(HttpNotFound());
            }

            if (guest.DidRsvp)
            {
                ViewBag.DidRsvp = true;
                if (guest.CanAttend == false)
                {
                    return(RedirectToAction("RsvpNo", new { userId = guest.Id }));
                }
            }

            var viewModel = new WeddingGuestViewModel();

            viewModel.InjectFrom(guest);

            return(View(viewModel));
        }