예제 #1
0
        // Custom ValidateHeaderAntiForgeryToken attribute validates anti-forgery token
        public ActionResult Submit(LeaseContactFormModel data)
        {
            // Sanitize
            HtmlSanitizer sanitizer = new HtmlSanitizer();

            sanitizer.AllowedAttributes.Clear();
            sanitizer.AllowedTags.Clear();
            data.Name      = sanitizer.Sanitize(data.Name.Trim());
            data.Email     = sanitizer.Sanitize(data.Email.Trim());
            data.Phone     = sanitizer.Sanitize(data.Phone.Trim());
            data.PageTitle = sanitizer.Sanitize(data.PageTitle.Trim());

            // Validate input data
            TryValidateModel(data);
            if (!ModelState.IsValid)
            {
                var firstError = ModelState.Values.SelectMany(x => x.Errors).First();
                Log.Write($"LeaseContactFormController - Submit: {firstError.ErrorMessage}",
                          ConfigurationPolicy.ErrorLog);

                return(Json(new { status = "error" }));
            }

            // Save data to database
            // TODO

            // Send email notification use InternalRecipients and EmailSubjectLine properties
            // TODO

            return(Json(new { status = "success" }, JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public bool SendLeaseContactFormNotification(LeaseContactFormModel leaseContact, string emailSubject, string recipients)
        {
            bool isSent = true;

            // TODO: implement

            return(isSent);
        }
예제 #3
0
        public ActionResult Index()
        {
            LeaseContactFormModel model = new LeaseContactFormModel();

            return(View("Default", model));
        }