Ejemplo n.º 1
0
        public async Task<ActionResult> Index(string message = "", bool hide_layout = false) {
            var pcats = CURTAPI.GetParentCategoriesAsync();
            await Task.WhenAll(new Task[] { pcats });
            ViewBag.parent_cats = await pcats;

            // Get all the Contact Types
            List<ContactType> types = ContactType.GetAll();
            ViewBag.types = types;

            // Get the contact ContentPage
            ContentPage page = ContentManagement.GetPageByTitle("contact");
            ViewBag.page = page;

            if (TempData["error"] != null) {
                message = TempData["error"].ToString();
            }
            ViewBag.message = message;

            ContactInquiry inquiry = new ContactInquiry();
            if (TempData["inquiry"] != null) {
                try{
                    inquiry = (ContactInquiry)TempData["inquiry"];
                }catch(Exception){}
            }
            ViewBag.inquiry = inquiry;
            ViewBag.hide_layout = hide_layout;

            return View();
        }
Ejemplo n.º 2
0
        public ActionResult Send(string name = null, string phone = null, string email = null, int contact_type = 0, string message = null) {

            ContactInquiry inq = new ContactInquiry();
            try {
                inq = new ContactInquiry {
                    name = name,
                    phone = phone,
                    email = email,
                    contact_type = contact_type,
                    message = message,
                    dateAdded = DateTime.UtcNow,
                    followedUp = 0
                };
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(System.Web.HttpContext.Current, Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"]);
                if (!recaptchavalid) throw new Exception("Captcha Incorrect!");

                UDF.Sanitize(inq, new string[] { "phone", "followedUp" });
                inq.Save();
                TempData["error"] = "Thank you for your inquiry, someone will contact you soon to follow up with your request.";
                return RedirectToAction("Index", "Contact");
            } catch (Exception e) {
                TempData["inquiry"] = inq;
                TempData["error"] = e.Message;
                return RedirectToAction("Index", "Contact");
            }
        }
        public string Get(int id) {
            Admin.Profile profile = ViewBag.profile ?? new Admin.Profile();
            TimeZoneInfo tz = TimeZoneInfo.FindSystemTimeZoneById(profile.timezone ?? "UTC");
            try {
                ContactInquiry inq = new ContactInquiry{ ID = id };
                ContactInquiry resp = inq.Get();
                SimpleInquiry simple = new SimpleInquiry {
                    ID = resp.ID,
                    name = resp.name,
                    phone = resp.phone,
                    message = resp.message,
                    email = resp.email,
                    type = (resp.ContactType != null && resp.ContactType.label != null) ? resp.ContactType.label : "N/A",
                    dateAdded = String.Format("{0:M/dd/yyyy} at {0:h:mm tt}", TimeZoneInfo.ConvertTimeFromUtc(resp.dateAdded, tz)) + " " + UDF.ShortTZ(tz, resp.dateAdded),
                    followedUp = resp.followedUp
                };

                return JsonConvert.SerializeObject(simple);
            } catch (Exception e) {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                Response.StatusDescription = e.Message;
                Response.Write(e.Message);
                return e.Message;
            }
        }
        public ActionResult SendAJAX(string name = null, string phone = null, string email = null, string to = null, string message = null, string recaptcha_challenge_field = null, string recaptcha_response_field = null)
        {
            string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];

            ContactInquiry inq = new ContactInquiry();
            try {
                inq = new ContactInquiry {
                    name = name,
                    phone = phone,
                    email = email,
                    contact_type = 0,
                    message = message,
                    dateAdded = DateTime.Now,
                    followedUp = 0
                };
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(recaptcha_challenge_field, recaptcha_response_field, remoteip);
                if (!recaptchavalid) throw new Exception("Captcha Incorrect!");

                UDF.Sanitize(inq, new string[] { "phone", "contact_type", "followedUp" });
                inq.Save(true, to);
                TempData["error"] = "Thank you for your contact inquiry. Someone will respond to your request in a timely matter.";
                return RedirectToAction("Index","Locations");
            } catch (Exception e) {
                TempData["error"] = "Sorry, an error has occurred while processing your request." + e.Message;
                return RedirectToAction("Index", "Locations");
            }
        }
        public ActionResult Send(string name = null, string phone = null, string email = null, int contact_type = 0, string message = null)
        {
            string remoteip = (Request.ServerVariables["HTTP_X_FORWARDED_FOR"] != null) ? Request.ServerVariables["HTTP_X_FORWARDED_FOR"] : Request.ServerVariables["REMOTE_ADDR"];

            ContactInquiry inq = new ContactInquiry();
            try {
                inq = new ContactInquiry {
                    name = name,
                    phone = phone,
                    email = email,
                    contact_type = contact_type,
                    message = message,
                    dateAdded = DateTime.Now,
                    followedUp = 0
                };
                bool recaptchavalid = ReCaptcha.ValidateCaptcha(Request.Form["recaptcha_challenge_field"], Request.Form["recaptcha_response_field"], remoteip);
                if (!recaptchavalid) throw new Exception("Captcha Incorrect!");

                UDF.Sanitize(inq, new string[] { "phone", "followedUp" });
                inq.Save();
                TempData["error"] = "Thank you for your inquiry, someone will contact you soon to follow up with your request.";
                return RedirectToAction("Index", "Contact");
            } catch (Exception e) {
                TempData["inquiry"] = inq;
                TempData["error"] = e.Message;
                return RedirectToAction("Index", "Contact");
            }
        }
        public ActionResult Index(string message = "", bool hide_layout = false)
        {
            // Get all the Contact Types
            List<ContactType> types = ContactType.GetAll();
            ViewBag.types = types;

            // Get the contact ContentPage
            ContentPage page = ContentManagement.GetPageByTitle("contact");
            ViewBag.page = page;

            if (TempData["error"] != null) {
                message = TempData["error"].ToString();
            }
            ViewBag.message = message;

            ContactInquiry inquiry = new ContactInquiry();
            if (TempData["inquiry"] != null) {
                try{
                    inquiry = (ContactInquiry)TempData["inquiry"];
                }catch(Exception){}
            }
            ViewBag.inquiry = inquiry;
            ViewBag.hide_layout = hide_layout;

            return View();
        }
 public void MarkResponded(int id) {
     try {
         ContactInquiry inq = new ContactInquiry { ID = id };
         inq.MarkResponded();
     } catch (Exception e) {
         Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
         Response.StatusDescription = e.Message;
         Response.Write(e.Message);
     }
 }
        public string Get(int id)
        {
            try {
                ContactInquiry inq = new ContactInquiry{ ID = id };
                ContactInquiry resp = inq.Get();
                SimpleInquiry simple = new SimpleInquiry {
                    ID = resp.ID,
                    name = resp.name,
                    phone = resp.phone,
                    message = resp.message,
                    email = resp.email,
                    type = (resp.ContactType != null && resp.ContactType.label != null) ? resp.ContactType.label : "N/A",
                    dateAdded = resp.dateAdded,
                    followedUp = resp.followedUp
                };

                return JsonConvert.SerializeObject(simple);
            } catch (Exception e) {
                Response.StatusCode = (int)System.Net.HttpStatusCode.InternalServerError;
                Response.StatusDescription = e.Message;
                Response.Write(e.Message);
                return e.Message;
            }
        }