Exemplo n.º 1
0
 private string SetMessage(ContactUsModel model)
 {
     return "Name: " + model.Name + Environment.NewLine +
                     (string.IsNullOrEmpty(model.PhoneNumber) ? "" : "Phone: " + model.PhoneNumber) + Environment.NewLine +
                     (string.IsNullOrEmpty(model.Email) ? "" : "Email: " + model.Email) + Environment.NewLine + Environment.NewLine +
                     "Message: " + model.ClientsMessage;
 }
Exemplo n.º 2
0
        public ActionResult ContactUs(ContactUsModel model)
        {
            if (ModelState.IsValid)
            {
                string message = SetMessage(model);

                var ec = new EmailClass();
                string sentMessage = ec.SendEmail(message);

                if (!string.IsNullOrEmpty(sentMessage))
                {
                    ModelState.AddModelError("", sentMessage);
                    return View("ContactUs", model);
                }

                return RedirectToAction("ContactUs", new { code = 1 });
            }
            return View("ContactUs", model);
        }
Exemplo n.º 3
0
        public ActionResult ContactUs(int? code)
        {
            var model = new ContactUsModel { MessageCode = code };

            return View(model);
        }