Exemplo n.º 1
0
        /// <summary>
        /// [YOGESH] - Validates and saves the TripHostOrder value to the DB.
        /// </summary>
        /// <param name="model">TripHostOrderViewModel</param>
        /// <returns></returns>
        public ActionResult SetNewsletterFormat(TripHostOrderViewModel model)
        {
            var    database = GetDatabase();
            string order    = null;

            if (!string.IsNullOrEmpty(model.Order))
            {
                order = model.Order.ToUpper();
                var regex = new Regex("^[TH]+$");
                if (!regex.IsMatch(order))
                {
                    order = null;
                }
            }
            if (order == null)
            {
                TempData["notification"] = "Please enter the trip-host order in the correct format.";
            }
            else
            {
                var tripHostOrder = database.GetAll <Settings>().Where(m => m.Id == "NewsLetterFormat").SingleOrDefault();
                tripHostOrder.TripHostOrder = order;
                database.Save(tripHostOrder);
                TempData["notification"] = "Trip-host order for the newsletter has been updated.";
            }

            return(RedirectToAction("index"));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            // [YOGESH] - Get the TripHostOrder setting form the DB.
            var database = GetDatabase();
            TripHostOrderViewModel tripHostOrderViewModel = new TripHostOrderViewModel();

            var tripHostOrder = database.GetAll<Settings>().Select(h => h.TripHostOrder).FirstOrDefault();
            // If the TripHostOrder is not set, get the default from te config file and save to the DB.
            if (string.IsNullOrEmpty(tripHostOrder))
            {
                Settings format = new Settings();
                format.TripHostOrder = DefaultTripHostOrder;
                format.Id = "NewsLetterFormat";
                database.Save(format);

                tripHostOrderViewModel.Order = DefaultTripHostOrder;
            }
            else
            {
                tripHostOrderViewModel.Order = tripHostOrder;
            }
            return View(tripHostOrderViewModel);
        }
Exemplo n.º 3
0
        public ActionResult Index()
        {
            // [YOGESH] - Get the TripHostOrder setting form the DB.
            var database = GetDatabase();
            TripHostOrderViewModel tripHostOrderViewModel = new TripHostOrderViewModel();

            var tripHostOrder = database.GetAll <Settings>().Select(h => h.TripHostOrder).FirstOrDefault();

            // If the TripHostOrder is not set, get the default from te config file and save to the DB.
            if (string.IsNullOrEmpty(tripHostOrder))
            {
                Settings format = new Settings();
                format.TripHostOrder = DefaultTripHostOrder;
                format.Id            = "NewsLetterFormat";
                database.Save(format);

                tripHostOrderViewModel.Order = DefaultTripHostOrder;
            }
            else
            {
                tripHostOrderViewModel.Order = tripHostOrder;
            }
            return(View(tripHostOrderViewModel));
        }
Exemplo n.º 4
0
        /// <summary>
        /// [YOGESH] - Validates and saves the TripHostOrder value to the DB.
        /// </summary>
        /// <param name="model">TripHostOrderViewModel</param>
        /// <returns></returns>
        public ActionResult SetNewsletterFormat(TripHostOrderViewModel model)
        {
            var database = GetDatabase();
            string order = null;
            if (!string.IsNullOrEmpty(model.Order))
            {
                order = model.Order.ToUpper();
                var regex = new Regex("^[TH]+$");
                if (!regex.IsMatch(order))
                    order = null;
            }
            if (order == null)
                TempData["notification"] = "Please enter the trip-host order in the correct format.";
            else
            {
                var tripHostOrder = database.GetAll<Settings>().Where(m => m.Id == "NewsLetterFormat").SingleOrDefault();
                tripHostOrder.TripHostOrder = order;
                database.Save(tripHostOrder);
                TempData["notification"] = "Trip-host order for the newsletter has been updated.";
            }

            return RedirectToAction("index");
        }