public ActionResult Manage(ServiceUser.user kh) { if (ModelState.IsValid) { //if (DALKhachHang.CheckEmailExisted(kh.email) == true && kh.email != User.Identity.Name) //{ // ModelState.AddModelError("", "Email đã tồn tại"); //} //else //{ //FormsAuthentication.SetAuthCookie(kh.email, true); //string e = kh.email; //string p = kh.password; //var user = DALKhachHang.GetKhachHangByEmail(kh.email); //user.password = kh.password; //user.name = kh.name; //user.phone_number = kh.phone_number; //user.address = kh.address; if (DALKhachHang.Update(kh)) { TempData["message"] = "Cập nhật thành công!"; //FormsAuthentication.SetAuthCookie(kh.email, true); return(RedirectToAction("Manage")); } else { //ModelState.AddModelError("", "Cập nhật thất bại"); TempData["message"] = "Cập nhật thất bại!"; //FormsAuthentication.SetAuthCookie(kh.email, true); return(RedirectToAction("Manage")); } //} } return(View(kh)); }
private static User ConvertUser(ServiceUser.user item) { User u = new User(); u.id = item.id; u.id_role = item.id_role; u.name = item.name; u.name_role = sRole.GetRoleWithId(item.id_role).name; u.email = item.email; u.password = item.password; u.phone_number = item.phone_number; u.address = item.address; return(u); }
public ActionResult Register(ServiceUser.user kh) { if (ModelState.IsValid) { if (DALKhachHang.CheckEmailExisted(kh.email) == false) { kh.id_role = 1;//user default is khachhang if (DALKhachHang.Insert(kh)) { return(Login(kh.email, kh.password)); } ModelState.AddModelError("", "Không thể thêm User"); } else { ModelState.AddModelError("", "Email đã tồn tại"); } } return(View()); }
public static bool Update(ServiceUser.user kh) { return(sUser.UpdateUser(kh)); }
public static bool Insert(ServiceUser.user kh) { return(sUser.AddUser(kh)); }
public static ServiceUser.user GetKhachHangByEmail(string email) { ServiceUser.user u = sUser.GetUserByEmail(email); return(u); }
public static User GetKhachHangById(int id) { ServiceUser.user u = sUser.GetUserById(id); return(ConvertUser(u)); }