public ActionResult Create(FeedBack feedback) { if (ModelState.IsValid) { var dao = new FeedBackDao(); long id = dao.Insert(feedback); if (id > 0) { return(RedirectToAction("Index", "FeedBack")); } else { ModelState.AddModelError("", "Không thêm được"); } } return(View("Index")); }
public ActionResult Create(LienHe id) { if (ModelState.IsValid) { var dao = new FeedBackDao(); long result = dao.Insert(id); if (result > 0) { return(RedirectToAction("Index", "News")); } else { ModelState.AddModelError("", "Thêm bài báo thất bại"); } } return(View("Index")); }
public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { var dao = new FeedBackDao(); if (dao.CheckUserName(model.UserName)) { ModelState.AddModelError("", "Tên đăng nhập đã tồn tại"); } else if (dao.CheckEmail(model.Email)) { ModelState.AddModelError("", "Email đã tồn tại"); } else { var user = new User(); user.Name = model.Name; user.Password = model.Password; user.Phone = model.Phone; user.Email = model.Email; user.Address = model.Address; user.CreatedDate = DateTime.Now; user.Status = true; if (!string.IsNullOrEmpty(model.ProvinceID)) { user.ProvinceID = int.Parse(model.ProvinceID); } if (!string.IsNullOrEmpty(model.DistrictID)) { user.DistrictID = int.Parse(model.DistrictID); } var result = dao.Insert(user); if (result > 0) { ViewBag.Success = "Đăng ký thành công"; model = new RegisterModel(); } else { ModelState.AddModelError("", "Đăng ký không thành công."); } } } return(View(model)); }
public ActionResult Index(FeedBack model) { if (ModelState.IsValid) { var dao = new FeedBackDao(); model.CreatedDate = DateTime.Now; model.Status = false; if (dao.Insert(model)) { TempData["Success"] = "Cảm ơn bạn đã liên hệ!"; return(Redirect("/")); } else { TempData["Error"] = "Thông tin bị lỗi, xin vui lòng gửi lại!"; } } return(View(model)); }
public ActionResult Create(FeedBack feedback) { if (ModelState.IsValid) { var dao = new FeedBackDao(); feedback.CreatedDate = DateTime.Now; feedback.Status = true; long id = dao.Insert(feedback); if (id > 0) { ViewBag.Success = "Phản hồi thành công. Cám ơn bạn đã đóng góp ý kiến."; ModelState.Clear(); } else { ModelState.AddModelError("", "Phản hồi không thành công"); } } return(View("Create")); }
//[HasCredential(RoleID = "ADD_USER")] public ActionResult Create(User user) { if (ModelState.IsValid) { var dao = new FeedBackDao(); var encryptedMd5Pas = Encryptor.MD5Hash(user.Password); user.Password = encryptedMd5Pas; long id = dao.Insert(user); if (id > 0) { SetAlert("Thêm user thành công", "success"); return(RedirectToAction("Index", "User")); } else { ModelState.AddModelError("", "Thêm user không thành công"); } } return(View("Index")); }