public ActionResult Logon(MemberModel model) { ModelState.Remove("IndustryId"); ModelState.Remove("Name"); ModelState.Remove("Company"); ModelState.Remove("CompanyNo"); ModelState.Remove("CompanyNum"); ModelState.Remove("CompanyTypeList"); ModelState.Remove("Email"); ModelState.Remove("RegDate"); ModelState.Remove("CheckPassword"); ModelState.Remove("ReceiveEpaperInfo"); string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("ConfirmationCode", "驗證碼錯誤"); } else { model.DoLogon(); } if (model.SendOrderOk) { return(View("LogOff", model)); } else { return(View(model)); } }
public ActionResult Join(MemberModel model) { ModelState.Remove("RegDate"); string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("ConfirmationCode", "驗證碼錯誤"); } else if (model.Password != model.CheckPassword) { ModelState.AddModelError("Password", ""); ModelState.AddModelError("CheckPassword", "登入密碼與確認密碼不一樣"); } else { if (model.IsValid()) { model.SendOrder(); } } if (model.SendOrderOk) { return(View("LogOff", model)); } else { return(View(model)); } }
public ActionResult SendOrder(EpaperExaminationModel model) { ModelState.Remove("PostDate"); ModelState.Remove("Question10"); ModelState.Remove("Question11"); ModelState.Remove("Question12"); string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("ConfirmationCode", "驗證碼錯誤"); } else { if (model.IsValid()) { model.Insert(); model.SendOrderOk = true; } } if (model.SendOrderOk) { return(View("SendOrderOK")); } else { return(View("Index", model)); } }
public ActionResult SendOrder(ReportModel model) { HttpPostedFileBase picFile = null; foreach (string file in Request.Files) { picFile = Request.Files[file] as HttpPostedFileBase; } ModelState.Remove("Name"); string captcha = AccountUtil.GetCaptcha(); if (picFile == null || picFile.ContentLength <= 0) { ModelState.AddModelError("ReportPic", "請選擇報告書封面圖片"); } else if (picFile.ContentLength > (1024 * 1024)) { ModelState.AddModelError("ReportPic", "請選擇小於 1MB 的報告書封面圖片"); } else if (!IsImage(picFile)) { ModelState.AddModelError("ReportPic", "請上傳圖片格式的報告書封面圖片"); } else if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("ConfirmationCode", "驗證碼錯誤"); } else { if (picFile.ContentLength > 0) { var fileName = Guid.NewGuid().ToString() + Path.GetExtension(picFile.FileName); var path = Path.Combine(AppSettings.CKFinderBaseDir, "webuser/images/", fileName); picFile.SaveAs(path); model.ReportPic = "webuser/images/" + fileName; } if (model.IsValid(ModelState)) { model.Status = "0"; model.Insert(); } } if (model.SendOrderOk) { ModelState.Clear(); } return(View("Provide2", model)); }
public ActionResult SendMail(SendMailModel model, string id) { NewsModel entityModel = new NewsModel(id); string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.SendMailConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError(string.Empty, "驗證碼錯誤"); } else { model.SendMailTitle = string.Format("收到一封由【{0}】從產業永續發展整合資訊網的轉寄信:{1}。" , model.SendMailName, entityModel.Name); model.SendMailContent += entityModel.Content; model.SendMail(); EntityCounter(id, "Emailer"); ViewData["SendMailOk"] = true; } return(View("Email", entityModel)); }
/// <summary> /// 測試用快速登入 /// </summary> /// <returns></returns> public virtual ActionResult TestLogon() { LogOnModel model = new LogOnModel() { Account = "admin", Password = "******", ConfirmationCode = AccountUtil.GetCaptcha() }; if (model.ValidateUser()) { return(!String.IsNullOrWhiteSpace(model.RtnUrl) ? (ActionResult)Redirect(model.RtnUrl) : RedirectToAction("Index", "Admin", new { RtnUrl = HttpContext.Request["RtnUrl"] })); } else { ModelState.AddModelError(string.Empty, "帳號密碼錯誤"); } return(View("LogOn")); }
public ActionResult SendOrder(EpaperEmailModel model) { string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError("ConfirmationCode", "驗證碼錯誤"); } else { if (model.IsValid()) { model.SendOrder(); } } if (model.SendOrderOk) { ModelState.Clear(); } return(View("Order", model)); }
public ActionResult LogOn(LogOnModel model) { string captcha = AccountUtil.GetCaptcha(); if (!captcha.Equals(model.ConfirmationCode, StringComparison.OrdinalIgnoreCase)) { ModelState.AddModelError(string.Empty, "驗證碼錯誤"); } else { if (model.ValidateUser()) { return(!String.IsNullOrWhiteSpace(model.RtnUrl) ? (ActionResult)Redirect(model.RtnUrl) : RedirectToAction("Index", "Admin", new { RtnUrl = HttpContext.Request["RtnUrl"] })); } else { ModelState.AddModelError(string.Empty, "帳號密碼錯誤"); } } return(View(model)); }