示例#1
0
        private bool SendMail(BugReportModel model)
        {
            var body = new StringBuilder();

            body.AppendLine("You recieved an bug report email via the mtgbot.tv website: ").AppendLine();

            body.AppendFormat("Email: {0}", model.Email).AppendLine();
            body.AppendFormat("Twitch Name: {0}", Session["user_name"]).AppendLine();

            if (Request.ServerVariables["HTTP_CF_CONNECTING_IP"] != null)
            {
                body.AppendFormat("IP Address (From Cloudflare): {0}", Request.ServerVariables["HTTP_CF_CONNECTING_IP"]).AppendLine();
            }
            else
            {
                body.AppendFormat("IP Address: {0}", Request.UserHostAddress).AppendLine();
            }

            if (Request.ServerVariables["X_FORWARDED_FOR"] != null)
            {
                body.AppendFormat("Forwarded For: {0}", Request.ServerVariables["X_FORWARDED_FOR"]).AppendLine();
            }

            body.AppendFormat("User Agent: {0}", Request.UserAgent).AppendLine().AppendLine().AppendLine();

            body.AppendLine("Bug:").AppendLine();
            body.AppendLine(model.Problem).AppendLine().AppendLine();
            body.AppendLine("Steps to reproduce:").AppendLine();
            body.AppendLine(model.Reproduce);

            return(Email.SendMessage("Bug Report from website", body.ToString(), model.Email));
        }
示例#2
0
        public ActionResult Bug(BugReportModel model)
        {
            if (ModelState.IsValid)
            {
                if (SendMail(model))
                {
                    return(View("Success"));
                }
            }

            return(View());
        }
示例#3
0
        public IActionResult Index(BugReportModel model)
        {
            if (model.CustomerName == null || model.CustomerName.Trim().Length == 0)
            {
                ModelState.AddModelError("Name", "Your Name is Required");
            }
            else if ((model.CustomerName).Length < 3)
            {
                ModelState.AddModelError("Name", "Please Enter a valid name (at least 3 characters)");
            }

            if (model.Email == null || model.Email.Trim().Length == 0)
            {
                ModelState.AddModelError("Email", "Your Email is Required");
            }
            else
            {
                string emailRegex = @"^\w+@\w+\.\w+|\w+\.\w+";
                Regex  re         = new Regex(emailRegex);
                if (!re.IsMatch(model.Email))
                {
                    ModelState.AddModelError("Email", "Please enter a valid Email");
                }
            }

            if (model.BugDesc == null || model.BugDesc.Trim().Length == 0)
            {
                ModelState.AddModelError("Description", "The Bug Description is required");
            }

            if (model.BugType == null || model.BugType.Trim().Length == 0)
            {
                ModelState.AddModelError("BugType", "Bug Type is Required");
            }

            if (model.CustomerType == null || model.CustomerType.Trim().Length == 0)
            {
                ModelState.AddModelError("CustomerType", "Customer type is required");
            }

            if (ModelState.IsValid)
            {
                //Submit to Api
                ModelState.Clear();
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
示例#4
0
        public ActionResult ReportBug()
        {
            BugReportModel vModel = new BugReportModel();

            return(View("~/Views/Shared/ReportBug.cshtml", "_chromelessLayout", vModel));
        }