public ActionResult Promo()
        {
            PromoFormViewModel model = new PromoFormViewModel();

            model.Message = "Describe your business problem";

            return(PartialView("_PromoFormPartial", model));
        }
        public async Task <ActionResult> ContactRequest(PromoFormViewModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    var entity = Mapper.Map <PromoFormViewModel, ContactRequest>(model);

                    entity.CreatedDate = DateTime.UtcNow;
                    entity.Ip          = Request.UserHostAddress;
                    _contactRequestService.Insert(entity);

                    try
                    {
                        var adminEmialAddress = System.Configuration.ConfigurationManager.AppSettings["AdminEmail"].ToString();

                        await MailSender.Default.SendAsync(
                            adminEmialAddress,
                            adminEmialAddress,
                            "New contact",
                            String.Format(@"
					                                   <h1>New contact from the website</h1>
					                                   <p><strong>Name:</strong> {0}</p>
					                                   <p><strong>Email:</strong> {1}</p>
					                                   <p><strong>Phone:</strong> {2}</p>
					                                   <p><strong>Message:</strong> {3}</p>
					                               "                    , model.FirstName, model.Email, model.Phone, model.Message));
                    }
                    catch { }

                    model.RedirectLink = Url.Action("ThankYou", "Home");

                    if (model.Mode.Equals("Short"))
                    {
                        return(new JsonResult
                        {
                            Data = model.RedirectLink
                        });
                    }

                    return(PartialView("_ContactRequestPartialView", model));
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("", e.Message);
                }
            }
            else
            {
                model.Errors = ModelState.Values.SelectMany(m => m.Errors)
                               .Select(e => e.ErrorMessage)
                               .ToList();
            }

            return(PartialView("_ContactRequestPartialView", model));
        }
        //
        // GET: /Promo/Edit/5
        public ActionResult Edit(int id)
        {
            var vm = new PromoFormViewModel(id);

            if (vm.ID == -1)
            {
                return(HttpNotFound());
            }
            return(View("EditPromoCode", vm));
        }
        //
        // GET: /Promo/Delete/5
        public ActionResult Delete(int id = 0)
        {
            var vm = new PromoFormViewModel(id);

            if (vm.ID == -1)
            {
                return(HttpNotFound());
            }
            return(View("DeletePromoCode", vm));
        }
 public ActionResult Create(PromoFormViewModel viewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (viewModel.Save(viewModel))
             {
                 return(RedirectToAction("List"));
             }
         }
         return(RedirectToAction("List"));
     }
     catch
     {
         return(RedirectToAction("Create"));
     }
 }
 public ActionResult Edit(PromoFormViewModel viewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (viewModel.Save(viewModel))
             {
                 return(RedirectToAction("List"));
             }
         }
         else
         {
             var errors = ModelState.Where(v => v.Value.Errors.Any());
             throw new ModelValidationException("ModelState Error");
         }
     }
     catch (Exception ex)
     {
         ViewData["Exception"] = "Exception: " + ex.Message + ex.InnerException + ex.StackTrace;
         return(RedirectToAction("Edit"));  // not sure this gets reached in the event of an error
     }
     return(RedirectToAction("Edit"));
 }
        //
        // GET: /Promo/Create
        public ActionResult Create()
        {
            var vm = new PromoFormViewModel();

            return(View("CreatePromoCode", vm));
        }
        //
        // GET: /Promo/Details/5
        public ActionResult Details(int id)
        {
            var vm = new PromoFormViewModel(id);

            return(View("PromoCodeDetails", vm));
        }