public ActionResult Page02(int id, Page02ViewData page02ViewData)
        {
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            try
            {
                TournamentRegistration newRegistrationData = new TournamentRegistration
                {
                    SchoolID = page02ViewData.SelectedSchool
                };

                // TODO: if case: Send an e-mail reporting database failure; could not find the record already added to the database
                this.Repository.UpdateTournamentRegistration(id, 2, newRegistrationData);
                return(this.RedirectToAction("Page03", new { id }));
            }
            catch (Exception exception)
            {
                ErrorSignal.FromCurrentContext().Raise(exception);

                // TODO: Replace with Error Message
                return(this.RedirectToAction("Index", "Home"));
            }
        }
        /// <summary>
        /// Concatenate all of the "Previous Positions Held" checked box values on Judges
        /// Registration Page 2.
        /// </summary>
        /// <param name="page02ViewData">
        /// The Page02 View Data.
        /// </param>
        /// <returns>
        /// A concatenated, semicolon-separated string of previously-held positions.
        /// </returns>
        private static string GetPreviousPositions(Page02ViewData page02ViewData)
        {
            StringBuilder previousPositions = new StringBuilder();

            if (page02ViewData.PreviouslyHeadJudge)
            {
                previousPositions.Append("Head Judge");
            }

            if (page02ViewData.PreviouslyProblemJudge)
            {
                previousPositions.Append(";Problem Judge");
            }

            if (page02ViewData.PreviouslyStyleJudge)
            {
                previousPositions.Append(";Style Judge");
            }

            if (page02ViewData.PreviouslyStagingJudge)
            {
                previousPositions.Append(";Staging Judge");
            }

            if (page02ViewData.PreviouslyTimekeeper)
            {
                previousPositions.Append(";Timekeeper");
            }

            if (page02ViewData.PreviouslyScorechecker)
            {
                previousPositions.Append(";Scorechecker");
            }

            if (page02ViewData.PreviouslyWeighInJudge)
            {
                previousPositions.Append(";Weigh-In Judge");
            }

            // If the first checked item wasn't "Head Judge", trim the leading ';'.
            if (previousPositions.Length > 0)
            {
                if (previousPositions[0] == ';')
                {
                    previousPositions.Remove(0, 1);
                }
            }
            else
            {
                // If the StringBuilder was empty after processing, return null so a NULL
                // is written to SQL Server.
                return(null);
            }

            return(previousPositions.ToString().Trim());
        }
        public ActionResult Page02(int id)
        {
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            Page02ViewData viewData = new Page02ViewData();

            this.SetBaseViewData(viewData);
            return(this.View(viewData));
        }
        public ActionResult Page02(int id)
        {
            // If registration is currently closed, down, or coming soon, redirect to the appropriate page.
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            Page02ViewData data = new Page02ViewData();

            this.InitializePage02ViewData(data);
            return(this.View(data));
        }
        public ActionResult Page02(int id)
        {
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            Page02ViewData viewData = new Page02ViewData
            {
                SchoolList = new SelectList(this.Repository.Schools, "ID", "Name")
            };

            this.SetBaseViewData(viewData);
            return(this.View(viewData));
        }
Exemplo n.º 6
0
        public ActionResult Page02(int id)
        {
            // If registration is currently closed, down, or coming soon, redirect to the appropriate page.
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            var viewData = new Page02ViewData
            {
                CoachesTrainingInfo = Repository.CoachesTrainingInfo,
            };

            this.SetBaseViewData(viewData);

            // Update the DateTime of the registration in the Judge record
            viewData.CoachesTraining = Repository.GetCoachesTrainingRegistrationById(id).FirstOrDefault();

            // This should NEVER happen
            if (viewData.CoachesTraining == null)
            {
                // Coaches Training record not found; return an error.
                viewData.ErrorMessage = "Your registration failed.  Please try the registration process over again.";
                return(this.View(viewData));
            }

            viewData.MailBody = this.GenerateEmailBody(viewData);

            // Instantiate a new instance of MailMessage
            var mailMessage = BuildMessage(
                viewData.Config["WebmasterEmail"],
                viewData.RegionName + " Odyssey Region " + viewData.RegionNumber + " " + viewData.FriendlyRegistrationName,
                viewData.MailBody,
                viewData.CoachesTraining.EmailAddress,
                null,
                null);

            // Instantiate a new instance of SmtpClient
            viewData.MailErrorMessage = this.SendMessage(viewData, mailMessage);

            return(this.View(viewData));
        }
        protected string GenerateEmailBody(Page02ViewData viewData)
        {
            string        input   = Regex.Replace(viewData.CoachesTrainingInfo.EventMailBody, "<span>Region</span>", "Region " + viewData.Config["RegionNumber"]);
            StringBuilder builder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationURL))
            {
                builder.Append("<a href=\"" + viewData.CoachesTrainingInfo.LocationURL + "\" target=\"_blank\">");
            }
            builder.Append(viewData.CoachesTrainingInfo.Location);
            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationAddress))
            {
                builder.Append(", " + viewData.CoachesTrainingInfo.LocationAddress);
            }
            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationCity))
            {
                builder.Append(", " + viewData.CoachesTrainingInfo.LocationCity);
            }
            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationState))
            {
                builder.Append(", " + viewData.CoachesTrainingInfo.LocationState);
            }
            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationURL))
            {
                builder.Append("</a>");
            }
            input = Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(Regex.Replace(input, "<span>Location</span>", builder.ToString()), "<span>Date</span>", viewData.CoachesTrainingInfo.StartDate.HasValue ? viewData.CoachesTrainingInfo.StartDate.Value.ToLongDateString() : "TBA"), "<span>Time</span>", !string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.Time) ? viewData.CoachesTrainingInfo.Time : "TBA"), "<span>Years</span>", viewData.Config["Year"] + " - " + viewData.Config["EndYear"]), "<span>ProgramGuide</span>", "<a href=\"" + viewData.Config["ProgramGuideURL"] + "\" target=\"_blank\">" + viewData.Config["ProgramGuideURL"] + "</a>");
            builder.Clear();
            if (viewData.Config.ContainsKey("CoachesHandbookURL") && !string.IsNullOrWhiteSpace(viewData.Config["CoachesHandbookURL"]))
            {
                builder.Append("<li>\ta copy of the Coaches Handbook from the Virginia state website (<a href=\"" + viewData.Config["CoachesHandbookURL"] + "\" target=\"blank\">" + viewData.Config["CoachesHandbookURL"] + "</a>),</li>\n");
            }
            input = Regex.Replace(Regex.Replace(Regex.Replace(input, "<span>VirginiaHandbook</span>", builder.ToString()), "<span>Fee</span>", viewData.CoachesTrainingInfo.EventCost), "<span>MakeChecksOutTo</span>", viewData.CoachesTrainingInfo.EventMakeChecksOutTo);
            builder.Clear();
            if (viewData.Config.ContainsKey("CoordinatorsDoNotPayCoachesTrainingRegistrationFee") && (viewData.Config["CoordinatorsDoNotPayCoachesTrainingRegistrationFee"].ToLower() == "true"))
            {
                builder.Append(viewData.Config["SchoolCoordinatorsDoNotPayMessage"]);
            }
            return(Regex.Replace(Regex.Replace(input, "<span>CoordinatorsDoNotPay</span>", builder.ToString()), "<span>RegionalDirectorEmail</span>", "<a href=\"mailto:" + viewData.Config["RegionalDirectorEmail"] + "\">" + viewData.Config["RegionalDirectorEmail"] + "</a>"));
        }
        public ActionResult Page02(int id, Page02ViewData page02ViewData)
        {
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }

            try
            {
                if (this.ModelState.IsValid)
                {
                    Volunteer newRegistrationData = new Volunteer
                    {
                        FirstName           = page02ViewData.FirstName,
                        LastName            = page02ViewData.LastName,
                        EveningPhone        = page02ViewData.EveningPhone,
                        DaytimePhone        = page02ViewData.DaytimePhone,
                        MobilePhone         = page02ViewData.MobilePhone,
                        EmailAddress        = page02ViewData.EmailAddress,
                        VolunteerWantsToSee = page02ViewData.VolunteerWantsToSee,
                        Notes = page02ViewData.Notes
                    };

                    // TODO: if case: Send an e-mail reporting database failure; could not find the record already added to the database
                    this.Repository.UpdateVolunteer(id, 2, newRegistrationData);
                    return(this.RedirectToAction("Page03", new { id }));
                }

                this.SetBaseViewData(page02ViewData);
                return(this.View(page02ViewData));
            }
            catch (Exception exception)
            {
                ErrorSignal.FromCurrentContext().Raise(exception);

                // TODO: Replace with Error Message.
                return(this.RedirectToAction("Index", "Home"));
            }
        }
        public ActionResult Page02(int id)
        {
            if (base.CurrentRegistrationState != BaseRegistrationController.RegistrationState.Available)
            {
                return(base.RedirectToAction(base.CurrentRegistrationState.ToString()));
            }
            Page02ViewData viewData = new Page02ViewData {
                CoachesTrainingInfo = base.Repository.CoachesTrainingInfo
            };

            base.SetBaseViewData(viewData);
            viewData.CoachesTraining = base.Repository.GetCoachesTrainingRegistrationById(id).FirstOrDefault <CoachesTrainingRegistration>();
            if (viewData.CoachesTraining == null)
            {
                viewData.ErrorMessage = "Your registration failed.  Please try the registration process over again.";
                return(base.View(viewData));
            }
            viewData.MailBody = this.GenerateEmailBody(viewData);
            MailMessage mailMessage = base.BuildMessage(viewData.Config["WebmasterEmail"], viewData.RegionName + " Odyssey Region " + viewData.RegionNumber + " " + viewData.FriendlyRegistrationName, viewData.MailBody, viewData.CoachesTraining.EmailAddress, null, null);

            viewData.MailErrorMessage = base.SendMessage(viewData, mailMessage);
            return(base.View(viewData));
        }
Exemplo n.º 10
0
        /// <summary>
        /// The generate email body.
        /// </summary>
        /// <param name="viewData">
        /// The view data.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        protected string GenerateEmailBody(Page02ViewData viewData)
        {
            string mailBody = viewData.CoachesTrainingInfo.EventMailBody;

            mailBody = Regex.Replace(mailBody, "<span>Region</span>", "Region " + viewData.Config["RegionNumber"]);

            StringBuilder stringBuilder = new StringBuilder();

            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationURL))
            {
                stringBuilder.Append("<a href=\"" + viewData.CoachesTrainingInfo.LocationURL + "\" target=\"_blank\">");
            }

            // Add the name of the Coaches Training location (as a link if a URL is present in the database).
            stringBuilder.Append(viewData.CoachesTrainingInfo.Location);

            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationAddress))
            {
                stringBuilder.Append(", " + viewData.CoachesTrainingInfo.LocationAddress);
            }

            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationCity))
            {
                stringBuilder.Append(", " + viewData.CoachesTrainingInfo.LocationCity);
            }

            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationState))
            {
                stringBuilder.Append(", " + viewData.CoachesTrainingInfo.LocationState);
            }

            // End the hyperlink code, if one is present in the database for Judges Training
            if (!string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.LocationURL))
            {
                stringBuilder.Append("</a>");
            }

            mailBody = Regex.Replace(mailBody, "<span>Location</span>", stringBuilder.ToString());

            mailBody = Regex.Replace(
                mailBody,
                "<span>Date</span>",
                viewData.CoachesTrainingInfo.StartDate != null ? viewData.CoachesTrainingInfo.StartDate.Value.ToLongDateString() : "TBA");

            mailBody = Regex.Replace(
                mailBody,
                "<span>Time</span>",
                !string.IsNullOrWhiteSpace(viewData.CoachesTrainingInfo.Time) ? viewData.CoachesTrainingInfo.Time : "TBA");

            mailBody = Regex.Replace(mailBody, "<span>Years</span>", viewData.Config["Year"] + " - " + viewData.Config["EndYear"]);

            mailBody = Regex.Replace(
                mailBody,
                "<span>ProgramGuide</span>",
                "<a href=\"" + viewData.Config["ProgramGuideURL"] + "\" target=\"_blank\">" + viewData.Config["ProgramGuideURL"] + "</a>");

            // Only include a reference to the Coaches Handbook from VA if a URL is specified in the database.
            stringBuilder.Clear();
            if (viewData.Config.ContainsKey("CoachesHandbookURL"))
            {
                if (!string.IsNullOrWhiteSpace(viewData.Config["CoachesHandbookURL"]))
                {
                    stringBuilder.Append(
                        "<li>\ta copy of the Coaches Handbook from the Virginia state website (<a href=\"" +
                        viewData.Config["CoachesHandbookURL"] + "\" target=\"blank\">" +
                        viewData.Config["CoachesHandbookURL"] + "</a>),</li>\n");
                }
            }

            mailBody = Regex.Replace(mailBody, "<span>VirginiaHandbook</span>", stringBuilder.ToString());
            mailBody = Regex.Replace(mailBody, "<span>Fee</span>", viewData.CoachesTrainingInfo.EventCost);
            mailBody = Regex.Replace(mailBody, "<span>MakeChecksOutTo</span>", viewData.CoachesTrainingInfo.EventMakeChecksOutTo);

            stringBuilder.Clear();
            if (viewData.Config.ContainsKey("CoordinatorsDoNotPayCoachesTrainingRegistrationFee"))
            {
                if (viewData.Config["CoordinatorsDoNotPayCoachesTrainingRegistrationFee"].ToLower() == "true")
                {
                    stringBuilder.Append(viewData.Config["SchoolCoordinatorsDoNotPayMessage"]);
                }
            }

            mailBody = Regex.Replace(mailBody, "<span>CoordinatorsDoNotPay</span>", stringBuilder.ToString());

            mailBody = Regex.Replace(
                mailBody,
                "<span>RegionalDirectorEmail</span>",
                "<a href=\"mailto:" + viewData.Config["RegionalDirectorEmail"] + "\">" + viewData.Config["RegionalDirectorEmail"] + "</a>");

            return(mailBody);
        }
        public ActionResult Page02(int id, Page02ViewData page02ViewData)
        {
            // If registration is currently closed, down, or coming soon, redirect to the appropriate page.
            if (this.CurrentRegistrationState != RegistrationState.Available)
            {
                return(this.RedirectToAction(this.CurrentRegistrationState.ToString()));
            }
            try
            {
                // TODO: What should we do here if the ModelState isn't valid? - Rob, 09/30/2014
                if (this.ModelState.IsValid)
                {
                    Judge newJudgeData = new Judge
                    {
                        FirstName                           = page02ViewData.FirstName,
                        LastName                            = page02ViewData.LastName,
                        Address                             = page02ViewData.Address,
                        AddressLine2                        = page02ViewData.AddressLine2,
                        City                                = page02ViewData.City,
                        State                               = page02ViewData.State,
                        ZipCode                             = page02ViewData.ZipCode,
                        EveningPhone                        = page02ViewData.EveningPhone,
                        DaytimePhone                        = page02ViewData.DaytimePhone,
                        MobilePhone                         = page02ViewData.MobilePhone,
                        EmailAddress                        = page02ViewData.EmailAddress,
                        ProblemChoice1                      = page02ViewData.ProblemChoice1,
                        ProblemChoice2                      = page02ViewData.ProblemChoice2,
                        ProblemChoice3                      = page02ViewData.ProblemChoice3,
                        HasChildrenCompeting                = page02ViewData.HasChildrenCompeting,
                        ProblemCOI1                         = page02ViewData.ProblemConflict1,
                        ProblemCOI2                         = page02ViewData.ProblemConflict2,
                        ProblemCOI3                         = page02ViewData.ProblemConflict3,
                        YearsOfLongTermJudgingExperience    = page02ViewData.YearsOfLongTermJudgingExperience,
                        YearsOfSpontaneousJudgingExperience = page02ViewData.YearsOfSpontaneousJudgingExperience,
                        PreviousPositions                   = GetPreviousPositions(page02ViewData),
                        WillingToBeScorechecker             = page02ViewData.WillingToBeScorechecker,
                        TshirtSize                          = page02ViewData.TshirtSize,
                        WantsCEUCredit                      = page02ViewData.WantsCeuCredit,
                        Notes                               = page02ViewData.Notes
                    };

                    // If the judge did not provide an e-mail address, make sure "None" is written to the database
                    if (string.IsNullOrWhiteSpace(newJudgeData.EmailAddress))
                    {
                        newJudgeData.EmailAddress = "None";
                    }

                    // TODO: if case: Send an e-mail reporting database failure; could not find the record already added to the database
                    this.Repository.UpdateJudge(id, 2, newJudgeData);

                    // Display debugging information.
                    ////Response.Write("<p>Head Judge: " + collection["PreviouslyHeadJudge"] + "</p>");
                    ////Response.Write("<p>Problem Judge: " + collection["PreviouslyProblemJudge"] + "</p>");
                    ////Response.Write("<p>Style Judge: " + collection["PreviouslyStyleJudge"] + "</p>");
                    ////Response.Write("<p>Staging Judge: " + collection["PreviouslyStagingJudge"] + "</p>");
                    ////Response.Write("<p>Timekeeper: " + collection["PreviouslyTimekeeper"] + "</p>");
                    ////Response.Write("<p>Scorechecker: " + collection["PreviouslyScorechecker"] + "</p>");
                    ////Response.Write("<p>WeighIn Judge: " + collection["PreviouslyWeighInJudge"] + "</p>");
                    ////Response.Write("Previous Positions: " + viewData.Judge.PreviousPositions);
                    ////return null;

                    return(this.RedirectToAction("Page03", new { id }));
                }

                this.InitializePage02ViewData(page02ViewData);

                return(this.View(page02ViewData));
            }
            catch (Exception exception)
            {
                ErrorSignal.FromCurrentContext().Raise(exception);

                // TODO: Replace with Error Message
                return(this.RedirectToAction("Index", "Home"));
            }
        }
 private void InitializePage02ViewData(Page02ViewData page02ViewData)
 {
     page02ViewData.TshirtSizes    = new SelectList(from x in new[] { "S", "M", "L", "XL", "XXL", "XXXL" } select new { value = x, text = x }, "value", "text");
     page02ViewData.ProblemChoices = new SelectList(this.Repository.ProblemChoices, "ProblemID", "ProblemName");
     this.SetBaseViewData(page02ViewData);
 }