Exemple #1
0
        public ActionResult EditEntry(EditContestEntryViewModel viewModel)
        {
            var entry = this._contestRepository.GetContestEntry(viewModel.ContestEntryId);

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

            this._contestRepository.Save();

            Success("Successfully updated your contest entry", true);

            return(RedirectToAction("ViewEntry", "Contest", new { contestId = entry.ContestId, email = entry.Email, code = entry.VerificationCode }));
        }
Exemple #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));
        }
 public void RemoveAcademyAwardsNomineeSelectionFromContestEntry(ContestEntry entry, AcademyAwardsContestEntrySelection selection)
 {
     entry.AcademyAwardsContestEntrySelections.Remove(selection);
 }
        public void AddAcademyAwardsNomineeSelectionToContestEntry(ContestEntry entry, AcademyAwardsContestEntrySelection selection)
        {
            if (entry.AcademyAwardsContestEntrySelections == null)
            {
                entry.AcademyAwardsContestEntrySelections = new List <AcademyAwardsContestEntrySelection>();
            }

            entry.AcademyAwardsContestEntrySelections.Add(selection);
        }