public ActionResult LogOn(string Username, string Password, string ReturnUrl) { Models.User u = new UserService().GetValidateUser(Username, FormsAuthentication.HashPasswordForStoringInConfigFile(Password, "MD5")); if (u == null) { ViewData.ModelState.AddModelError("Username", "Tên đăng nhập hoặc mật khẩu không đúng. vui lòng kiểm tra và nhập lại"); return View(); } SessionManager.Profile = new Profile() { Id = u.Id, Role = u.MixRole, Name = u.Name, User = u }; return this.RedirectFromLoginPage(u.Name, ReturnUrl); }
public ActionResult ListByRole(int page, int rows, string sidx, string sord, int RoleId) { var users = new UserService().List(RoleId); bool searchOn = bool.Parse(Request.Form["_search"]); string searchExp = ""; if (searchOn) { searchExp = string.Format("{0}.ToString().Contains(@0)", getFormValue("searchField")); users = users.Where(searchExp, new string[] { getFormValue("searchString") }); } var model = from entity in users.OrderBy(sidx + " " + sord) select new { Id = entity.Id, Name = entity.Name, Username = entity.Username, Status = entity.Status, Password = "", }; return Json(model.ToJqGridData(page, rows, null, "", new[] { "Name", "Username", "Status" }), JsonRequestBehavior.AllowGet); }
// // GET: /User/Edit/5 public ActionResult Edit(int? id) { Models.User user = new UserService().GetItem(id); if (user == null) return RedirectToAction("List"); ViewData["RoleIds"] = (from u in user.UserInRoles select u.RoleId).ToList(); ViewData.Model = user; return View(); }