Exemplo n.º 1
0
        public ActionResult SignUp(int?contestId)
        {
            if (contestId == null)
            {
                contestId = CoreConfiguration.ActiveContestId;
            }

            if (contestId != null)
            {
                ContestSignUpViewModel viewModel = new ContestSignUpViewModel();
                viewModel.ContestId  = Convert.ToInt32(contestId);
                viewModel.Contest    = this._contestRepository.GetContest(Convert.ToInt32(contestId));
                viewModel.Categories = new List <ContestCategoryViewModel>();

                foreach (var category in viewModel.Contest.AcademyAwardsCategories)
                {
                    ContestCategoryViewModel cat = new ContestCategoryViewModel();
                    cat.CategoryId    = category.Id;
                    cat.CategoryTitle = category.CategoryTitle;
                    cat.SortOrder     = category.SortOrder;
                    cat.Nominees      = new List <ContestNomineeViewModel>();

                    foreach (var nominee in category.AcademyAwardsNominees)
                    {
                        cat.Nominees.Add(new ContestNomineeViewModel()
                        {
                            NomineeId = nominee.Id, NomineeText = nominee.NomineeText, SortOrder = nominee.SortOrder
                        });
                    }

                    viewModel.Categories.Add(cat);
                }

                return(View(viewModel));
            }

            Danger("There is no contest to sign up for at this time");

            return(RedirectToAction("Index", "Contest"));
        }
Exemplo n.º 2
0
        public ActionResult SignUp(ContestSignUpViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var contestEntry = new ContestEntry();
                contestEntry.Email     = viewModel.Email;
                contestEntry.ContestId = viewModel.ContestId;
                contestEntry.CreatedBy = "ContestController.SignUp()";
                this._contestRepository.AddEntry(contestEntry);

                foreach (var category in viewModel.Categories)
                {
                    if (category.SelectedNomineeId != null)
                    {
                        var selection = new AcademyAwardsContestEntrySelection()
                        {
                            AcademyAwardsCategoryId = category.CategoryId, SelectedAcademyAwardNomineeId = Convert.ToInt32(category.SelectedNomineeId)
                        };
                        this._contestRepository.AddAcademyAwardsNomineeSelectionToContestEntry(contestEntry, selection);
                    }
                }

                this._contestRepository.Save();

                var callbackUrl = string.Format(CoreConfiguration.VerifyContestFormatURL, HttpUtility.UrlEncode(contestEntry.ContestId.ToString()), HttpUtility.UrlEncode(contestEntry.Email), HttpUtility.UrlEncode(contestEntry.VerificationCode));
                EmailService.SendEmail(viewModel.Email, string.Format("{0} - Contest Entry Verification", CoreConfiguration.EmailSubjectTitle), string.Format("Thank you for signing up for our contest.<br /><br />Please click <a href='{0}'>here</a> to verify your email address.<br /><br />Your entry is not valid until you verify your email address.<br /><br />Email: <strong>{1}</strong><br /><br />Verification Code: <strong>{2}</strong><br />", callbackUrl, contestEntry.Email, contestEntry.VerificationCode));

                Success("Successfully submitted your contest entry. Your entry is not complete until you verify your email address by clicking the link when was sent to you", true);

                return(RedirectToAction("Index", "Contest"));
            }
            else
            {
                Danger("Email is required to sign up for contest", true);
            }

            return(View(viewModel));
        }