public ActionResult ForgotPassword(string email = "", string pwn = "", string confirmpw = "") { ViewBag.Email = email; if (pwn.Equals(confirmpw)) { if (CataLogBLL.CheckEmail(email) != 0) { UserAccountBLL.ChangePassword(MaHoaMD5Hepler.EncodeMD5(pwn), email); return(RedirectToAction("SignIn", "Account")); } else { ModelState.AddModelError("Messege", "Email không tồn tại!"); return(View()); } } else { ModelState.AddModelError("Messege", "Mật Khẩu không khớp!"); return(View()); } }
public ActionResult Input(Employee model, HttpPostedFileBase uploadFile, string EmailNew) { // Up anh if (uploadFile != null) { string fileName = $"{DateTime.Now.Ticks}{Path.GetExtension(uploadFile.FileName)}"; // string _fileName = string.Format{"{0}{1}"} $"{DateTime.Now.Ticks}{Path.GetExtension(uploadFile.FileName)}"; // string _FileName = Path.GetFileName(uploadFile.FileName); string filePath = Path.Combine(Server.MapPath("~/Images"), fileName); uploadFile.SaveAs(filePath); model.PhotoPath = fileName; } try { if (string.IsNullOrEmpty(model.FirstName)) { ModelState.AddModelError("FirstName", "FirstName expected"); } if (string.IsNullOrEmpty(model.LastName)) { ModelState.AddModelError("LastName", "LastName expected"); } if (string.IsNullOrEmpty(model.Title)) { ModelState.AddModelError("Title", "Title expected"); } if (string.IsNullOrEmpty(EmailNew)) { ModelState.AddModelError("Email", "Email expected!"); } if (string.IsNullOrEmpty(model.Address)) { model.Address = ""; } if (string.IsNullOrEmpty(model.City)) { model.City = ""; } if (string.IsNullOrEmpty(model.Country)) { model.Country = ""; } if (string.IsNullOrEmpty(model.HomePhone)) { model.HomePhone = ""; } if (string.IsNullOrEmpty(model.Notes)) { model.Notes = ""; } if (string.IsNullOrEmpty(model.PhotoPath)) { model.PhotoPath = ""; } if (string.IsNullOrEmpty(model.Password)) { model.Password = ""; } if (CataLogBLL.CheckEmail(EmailNew) != 0 && EmailNew.Equals(model.Email) == false) { ModelState.AddModelError("Email", "Email đã có người dùng!"); ViewBag.Title = model.EmployeeID == 0 ? "Create new Employee" : "Edit a Employee"; Employee editEmployee = CataLogBLL.GetEmployee(Convert.ToInt32(model.EmployeeID)); return(View(editEmployee)); } else { model.Email = EmailNew; } if (!ModelState.IsValid) { ViewBag.Title = model.EmployeeID == 0 ? "Create new Employee" : "Edit a Employee"; Employee editEmployee = CataLogBLL.GetEmployee(Convert.ToInt32(model.EmployeeID)); return(View(editEmployee)); } if (model.EmployeeID == 0) { CataLogBLL.AddEmployee(model); } else { CataLogBLL.UpdateEmployee(model); } return(RedirectToAction("Index")); } catch (Exception ex) { return(Content(ex.Message + "" + ex.StackTrace)); } }