public ActionReSult DuyetSanPham(int id) { using (DauGiaEntities ctx = new DauGiaEntities()) { SanPham sp = ctx.SanPhams.Single(c => c.MaSanPham == id); if (sp != null) { sp.DaDuyet = true; } ctx.SaveChanges(); } return(RedirectToAction("Index", "Manager")); }
public ActionResult Register(RegisterModel model) { var response = Request["g-recaptcha-response"]; string secretKey = "6LcnAycUAAAAAAklEw73MX5LijDgWstP5fHZefSc"; var client = new WebClient(); var result = client.DownloadString(string.Format("https://www.google.com/recaptcha/api/siteverify?secret={0}&response={1}", secretKey, response)); var obj = JObject.Parse(result); var status = (bool)obj.SelectToken("success"); if (ModelState.IsValid == false) { ViewBag.Error = "Xin nhập thông tin."; return(View(model)); } if (status == false) { ViewBag.Error = "ReCaptcha chưa được thực hiện."; return(View(model)); } using (DauGiaEntities ql = new DauGiaEntities()) { int n = ql.NguoiDung .Where(us => us.TaiKhoan == model.Ten) .Count(); if (n == 1) { ViewBag.Error = model.Ten + " đã có trong hệ thống"; return(View(model)); } } ViewBag.TenDangNhap = model.Ten; NguoiDung tk = new NguoiDung { TaiKhoan = model.Ten, MatKhau = StringUtils.Md5(model.MK), Email = model.Email, TenNguoiDung = model.FullName, PhanQuyen = 1,// user nguoi dung }; using (DauGiaEntities ctx = new DauGiaEntities()) { ctx.NguoiDung.Add(tk); ctx.SaveChanges(); ModelState.Clear(); } return(RedirectToAction("Login", "Account")); }
public ActionResult profilepass(Profile pr) { using (DauGiaEntities ql = new DauGiaEntities()) { string encPW = StringUtils.Md5(pr.Oldpass); NguoiDung tk = ql.NguoiDung.Where(p => p.MaNguoiDung == pr.MaTK).FirstOrDefault(); if (tk.MatKhau == encPW) { tk.MatKhau = StringUtils.Md5(pr.NewPass).ToString(); tk.Email = pr.EmailNew; tk.TenNguoiDung = pr.NameNew; ql.SaveChanges(); return(RedirectToAction("Index", "Home")); } else { ViewBag.Error = "Cập nhật thất bại!"; return(View(tk)); } } }