Example #1
0
        /// <summary>
        /// The index.
        /// </summary>
        /// <returns>
        /// The <see cref="ActionResult"/>.
        /// </returns>
        public ActionResult Index()
        {
            if (Properties.Settings.Default.SetBackDays != 0)
            {
                startDate = DateTime.Now.Date.AddDays(-1 * SetBackDays);
            }

            this.logger.Trace($"Index Calling Interface.GetEventsByProgram using {EventRegistrationId}");
            var events = Interface.GetEventsByProgram(EventRegistrationId, startDate);

            if (!events.Any())
            {
                return(this.RedirectToAction("Closed"));
            }

            // create states drop down list
            IEnumerable <SelectListItem> states     = StatesRepository.GetStates();
            IEnumerable <SelectListItem> selectList = GetSelectList(events);

            Form form = new Form()
            {
                States  = states,
                Events  = selectList,
                Message = Properties.Settings.Default.AlertMessage
            };

            return(this.View(form));
        }
Example #2
0
        public ActionResult Index(Form data)
        {
            this.logger.Trace($"Index Post Calling Interface.GetEventsByProgram to get drop down list of events for Program {EventRegistrationId}");
            if (Properties.Settings.Default.SetBackDays != 0)
            {
                startDate = DateTime.Now.Date.AddDays(-1 * SetBackDays);
            }

            List <EventData> events = Interface.GetEventsByProgram(EventRegistrationId, startDate);

            data.Events = GetSelectList(events);

            if (!events.Any())
            {
                return(this.RedirectToAction("Closed"));
            }

            // create states drop down list - note - move to default constructor
            IEnumerable <SelectListItem> states = StatesRepository.GetStates();

            data.States = states;
            if (!Properties.Settings.Default.devMode && this.ModelState.IsValid)
            {
                this.VerifyCaptcha("CaptchaError");
            }

            this.ViewBag.PublicKey = WebConfigurationManager.AppSettings["recaptchaPublicKey"];

            if (!this.ModelState.IsValid)
            {
                return(this.View(data));
            }

            EventData item = Interface.GetEvent(EventRegistrationId, data.SelectedEvent);

            if (item == null)
            {
                return(this.RedirectToAction("Error"));
            }

            // todo: consider moving dup check to AddRegistration
            if (!Properties.Settings.Default.AllowDuplicates)
            {
                if (this.CheckDuplicate(data))
                {
                    string ccpEmail = this.GetCampusEmail(item.CampusName);
                    return(this.View("Duplicate", null, ccpEmail));
                }
            }

            RegistrationData reg = this.AddRegistration(data);

            // todo : need a status and/or message to be returned to check for ok or dup.
            if (reg == null)
            {
                // API returned an error
                return(this.RedirectToAction("Error"));
            }

            bool isSentEmail = this.SendEmail(reg.EmailAddress, item);

            return(this.RedirectToAction(isSentEmail ? "Thanks" : "Error"));
        }
 /// <summary>
 /// This method is used to Retrive all states
 /// </summary>
 /// <remarks>
 /// DateCreated: 24th Oct 2016
 /// Edited By: Rakesh (25-Oct-2016) , Phani (3-Nov-2016)
 /// </remarks>
 /// <returns>List of States</returns>
 public IEnumerable <State> GetStates()
 {
     return(objStatesRepository.GetStates());
 }