public ActionResult Delete(int id) { IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); try { user model = _MemberShipProvider.GetUser(id, false); string[] roles = _RoleProvider.GetRolesForUser(model.userid); if (model.username.ToUpper() == HttpContext.User.Identity.Name.ToUpper() || roles.Contains("ServiceRole")) { Messages.AddErrorFlashMessage("Không được xóa tài khoản đang sử dụng."); return(RedirectToAction("index")); } if (!_MemberShipProvider.DeleteUser(model.userid, true)) { Messages.AddErrorFlashMessage("Chưa xóa được tài khoản."); } else { Messages.AddFlashMessage("Xóa tài khoản thành công!"); } } catch (Exception ex) { log.Error(ex); Messages.AddErrorFlashMessage("Có lỗi xảy ra, vui lòng thực hiện lại."); } return(RedirectToAction("index")); }
public ActionResult ServiceRoleIndex(string username, int?page) { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IuserService _userService = IoC.Resolve <IuserService>(); int defautPageSize = 10; int currentPageIndex = page.HasValue ? page.Value - 1 : 0; Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; IQueryable <user> query = _userService.Query.Where(p => p.GroupName.Equals(currentCom.id.ToString())); IList <user> lst; int total = 0; List <String> temp = new List <String>(_RoleProvider.GetUsersInRole("ServiceRole")); if (!string.IsNullOrWhiteSpace(username)) { query = query.Where(u => u.username.ToUpper().Contains(username.ToUpper().Trim()) && temp.Contains(u.username)).OrderByDescending(i => i.userid); total = query.Count(); lst = query.Skip(currentPageIndex * defautPageSize).Take(defautPageSize).ToList(); } else { query = query.Where(u => temp.Contains(u.username)).OrderByDescending(i => i.userid); total = query.Count(); lst = query.Skip(currentPageIndex * defautPageSize).Take(defautPageSize).ToList(); } IPagedList <user> model = new PagedList <user>(lst, currentPageIndex, defautPageSize, total); ViewData["username"] = username; return(View(model)); }
public ActionResult Update(int userid, string RetypePassword, string[] AssignRoles) { if (userid <= 0) { throw new HttpRequestValidationException(); } IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); AccountModels model = new AccountModels(); user _model = _MemberShipProvider.GetUser(userid, false); string oldpassHash = _model.password; //giu lai username khong cho sua string username = _model.username; try { TryUpdateModel(_model); if (_model.username != username) { throw new HttpRequestValidationException(); } AssignRoles = AssignRoles ?? new string[] { }; if (_model.password != RetypePassword) { List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = oldpassHash; model.AllRoles = lst.ToArray(); model.UserRoles = _RoleProvider.GetRolesForUser(_model.username); model.tmpUser = _model; Messages.AddErrorMessage("Nhập đúng mật khẩu của bạn."); return(View("Edit", model)); } if (RetypePassword != oldpassHash) { _model.password = FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5"); } _model.FailedPasswordAttemptCount = 0; _MemberShipProvider.UpdateUser(_model); _RoleProvider.UpdateUsersToRoles(_model.username, AssignRoles); Messages.AddFlashMessage("Cập nhật thông tin thành công."); logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Update : " + string.Format("Update: {0} by {1}", _model.username, HttpContext.User.Identity.Name), "Update User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser); return(RedirectToAction("index")); } catch (Exception ex) { logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Update ", "Update User Error " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = oldpassHash; model.AllRoles = lst.ToArray(); model.UserRoles = _RoleProvider.GetRolesForUser(_model.username); model.tmpUser = _model; Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!"); return(View("Edit", model)); } }
public ActionResult Active(ActiveModels model, string captch) { if (string.IsNullOrWhiteSpace(captch)) { model.ErrMessages = "Nhập đúng mã xác thực."; return(View(model)); } bool cv = CaptchaController.IsValidCaptchaValue(captch); if (!cv) { model.ErrMessages = "Nhập đúng mã xác thực."; return(View(model)); } try { if (string.IsNullOrWhiteSpace(model.username)) { model.ErrMessages = "Không tồn tại tài khoản trong hệ thống."; return(View(model)); } if (model.username != System.Text.Encoding.UTF8.GetString(Convert.FromBase64String(model.code))) { model.ErrMessages = "Không tồn tại tài khoản trong hệ thống."; return(View(model)); } Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); if (_MemberShipProvider.GetUser(model.username, true) != null) { model.ErrMessages = "Tài khoản đã được kích hoạt trước đó, liên hệ để được hỗ trợ."; return(View("Active", model)); } if (!model.password.Equals(model.comfirmpassword)) { model.ErrMessages = "Nhập đúng mật khẩu xác thực."; return(View("Active", model)); } string status = ""; user tmp = _MemberShipProvider.CreateUser(model.username, model.password, currentComp.Email, null, null, true, null, currentComp.id.ToString(), out status); if (status != "Success" || tmp == null) { model.ErrMessages = "Chưa kích hoạt được tài khoản, liên hệ để được hỗ trợ."; return(View("Active", model)); } IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); if (_RoleProvider.RoleExists("Admin")) { _RoleProvider.UpdateUsersToRoles(tmp.userid, new string[] { "Admin" }); } return(Redirect("/Account/Logon")); } catch (Exception ex) { log.Error(ex); model.ErrMessages = "Chưa kích hoạt được tài khoản, liên hệ để được hỗ trợ."; return(View()); } }
public ActionResult NewServiceRole() { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IuserService _userService = IoC.Resolve <IuserService>(); user _model = new user(); Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; _model.GroupName = currentCom.id.ToString(); ViewData["RetypePassword"] = _model.password; return(View(_model)); }
public ActionResult SaveServiceRole(int userid, string RetypePassword) { if (userid <= 0) { throw new HttpRequestValidationException(); } IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; user model = _MemberShipProvider.GetUser(userid, false); if (HttpContext.User.Identity.Name == model.username) { Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit); return(RedirectToAction("ServiceRoleIndex")); } string oldpassHash = model.password; string username = model.username; string email = model.email; try { TryUpdateModel(model); model.username = username; if (model.password != RetypePassword) { ViewData["RetypePassword"] = model.password; Messages.AddErrorFlashMessage(Resources.Message.User_MesConfirmPass); return(View("ServiceRoleEdit", model)); } if (RetypePassword != oldpassHash) { model.password = GeneratorPassword.EncodePassword(RetypePassword, model.PasswordFormat, model.PasswordSalt);//FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5"); } model.FailedPasswordAttemptCount = 0; _MemberShipProvider.UpdateUser(model); _RoleProvider.UpdateUsersToRoles(model.username, new string[] { "ServiceRole" }); Messages.AddFlashMessage(Resources.Message.User_UMesSuccess); log.Info("ServiceRoleUpdate by: " + HttpContext.User.Identity.Name + "Info-- tai khoan " + model.username); return(RedirectToAction("ServiceRoleIndex")); } catch (Exception ex) { ViewData["RetypePassword"] = model.password; log.Error("ServiceRoleUpdate-" + ex.Message); Messages.AddFlashException(ex); return(View("ServiceRoleEdit", model)); } }
public ActionResult Edit(int id) { IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; user oUser = _MemberShipProvider.GetUser(id, false); if (HttpContext.User.Identity.Name == oUser.username) { Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit); return(RedirectToAction("index")); } IStaffService _staSrv = IoC.Resolve <IStaffService>(); ViewData["fullname"] = _staSrv.SearchByAccountName(oUser.username, currentComp.id).FullName; AccountModel model = new AccountModel(); model.UserTmp = oUser; try { model.UserRoles = _RoleProvider.GetRolesForUser(oUser.userid); if (model.UserRoles.Contains("ServiceRole")) { Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit); return(RedirectToAction("index")); } List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = oUser.password; model.AllRoles = lst.ToArray(); } catch (Exception ex) { log.Error("edit: " + id, ex); throw ex; } return(View(model)); }
public ActionResult New() { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IuserService _userService = IoC.Resolve <IuserService>(); user _model = new user(); _model.IsApproved = true; AccountModels model = new AccountModels(); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; model.tmpUser = _model; return(View(model)); }
public ActionResult CreateNewServiceRole(user _model, string RetypePassword) { if (string.IsNullOrWhiteSpace(_model.username)) { Messages.AddErrorMessage("Cần nhập tên tài khoản người dùng."); ViewData["RetypePassword"] = _model.password; return(View("NewServiceRole", _model)); } Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); try { string status = ""; if (!_model.password.Equals(RetypePassword)) { Messages.AddErrorMessage(Resources.Message.User_MesConfirmPass); ViewData["RetypePassword"] = _model.password; return(View("NewServiceRole", _model)); } else { _model.GroupName = currentCom.id.ToString(); _MemberShipProvider.CreateUser(_model.username, _model.password, _model.email, _model.PasswordQuestion, _model.PasswordAnswer, _model.IsApproved, _model.userid, _model.GroupName, out status); if (status != "Success") { Messages.AddErrorMessage("Dữ liệu không hợp lệ hoặc tài khoản đã có trên hệ thống."); ViewData["RetypePassword"] = _model.password; return(View("NewServiceRole", _model)); } string[] roleservice = new string[] { "ServiceRole" }; _RoleProvider.UpdateUsersToRoles(_model.username, roleservice); Messages.AddFlashMessage(Resources.Message.User_IMesSuccess); log.Info("CreateNewServiceRole by:" + HttpContext.User.Identity.Name + " Info-- tai khoan " + _model.username); return(RedirectToAction("ServiceRoleIndex")); } } catch (Exception ex) { Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại."); log.Error("CreateNewServiceRole-" + ex.Message); ViewData["RetypePassword"] = _model.password; return(View("NewServiceRole", _model)); } }
public ActionResult Create() { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); AccountModel model = new AccountModel(); model.UserTmp = new user(); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; return(View(model)); }
public ActionResult Edit(int id) { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); user _model = _MemberShipProvider.GetUser(id, false); if (HttpContext.User.Identity.Name == _model.username) { Messages.AddErrorFlashMessage("Không được sửa tài khoản này."); return(RedirectToAction("index")); } AccountModels model = new AccountModels(); user muser = _MemberShipProvider.GetUser(id, false); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = muser.password; model.AllRoles = lst.ToArray(); model.UserRoles = _RoleProvider.GetRolesForUser(muser.username); model.tmpUser = _model; return(View(model)); }
public IHttpActionResult UserdataInfo(UserdataInfo data) { IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); if (string.IsNullOrWhiteSpace(data.username) || string.IsNullOrWhiteSpace(data.password)) { return(Ok <string>("ERROR:1"));//Cần nhập đủ thông tin } try { //Tao tai khoan string status = ""; user u = _MemberShipProvider.GetUser(data.username, false); if (u != null) { u.email = data.email; if (data.ChangePass) { u.password = GeneratorPassword.EncodePassword(data.password, u.PasswordFormat, u.PasswordSalt); } u.FailedPasswordAttemptCount = 0; //update lai tai khoan _MemberShipProvider.UpdateUser(u); return(Ok <string>("OK")); } Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; _MemberShipProvider.CreateUser(data.username, data.password, data.email, null, null, data.IsApproved, null, currentCom.id.ToString(), out status); if (status != "Success") { return(Ok <string>("ERROR:2"));//Status != Success } return(Ok <string>("OK")); } catch (Exception ex) { return(Ok <string>("ERROR:3")); } }
public ActionResult Create(user _model, string RetypePassword, string[] AssignRoles) { IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); IuserService _userService = IoC.Resolve <IuserService>(); IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); AccountModels model = new AccountModels(); if (string.IsNullOrWhiteSpace(_model.username)) { Messages.AddErrorMessage("Cần nhập những thông tin bắt buộc."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = AssignRoles ?? new string[] { }; model.tmpUser = _model; return(View("New", model)); } try { string status = ""; AssignRoles = AssignRoles ?? new string[] { }; if (!_model.password.Equals(RetypePassword)) { Messages.AddErrorMessage("Nhập đúng mật khẩu của bạn."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; model.tmpUser = _model; return(View("New", model)); } else { _MemberShipProvider.CreateUser(_model.username, _model.password, _model.email, _model.PasswordQuestion, _model.PasswordAnswer, _model.IsApproved, null, out status); if (status != "Success") { List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; model.tmpUser = _model; Messages.AddErrorMessage("Tài khoản đã có trên hệ thống hoặc dữ liệu không hợp lệ."); return(View("New", model)); } if (AssignRoles == null) { Messages.AddFlashMessage("Bạn tạo tài khoản thành công nhưng chưa phân quyền!"); return(RedirectToAction("index")); } _RoleProvider.UpdateUsersToRoles(_model.username, AssignRoles); Messages.AddFlashMessage("Tạo tài khoản thành công."); logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Create : " + string.Format("Create: {0} by {1}", _model.username, HttpContext.User.Identity.Name), "Create User Success ", LogType.Success, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser); return(RedirectToAction("index")); } } catch (Exception ex) { logSrv.CreateNew(FXContext.Current.CurrentUser.userid, "User - Create ", "Create User Error: " + ex, LogType.Error, HttpContext.Request.UserHostAddress, HttpContext.Request.Browser.Browser); Messages.AddErrorMessage("Chưa tạo được người dùng."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); model.RetypePassword = _model.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; model.tmpUser = _model; return(View("New", model)); } }
public ActionResult New(user temp, string RetypePassword, string[] UserRoles, string fullname) { IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); if (string.IsNullOrWhiteSpace(temp.username)) { AccountModel model = new AccountModel(); Messages.AddErrorMessage("Cần nhập những thông tin bắt buộc."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = temp.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = UserRoles ?? new string[] { }; model.UserTmp = temp; return(View("Create", model)); } try { if (temp.password != RetypePassword) { AccountModel model = new AccountModel(); Messages.AddErrorMessage(Resources.Message.User_MesConfirmPass); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = temp.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = UserRoles ?? new string[] { }; model.UserTmp = temp; return(View("Create", model)); } //Tao tai khoan string status = ""; Company currentCom = ((EInvoiceContext)FXContext.Current).CurrentCompany; user u = _MemberShipProvider.CreateUser(temp.username, temp.password, temp.email, null, null, temp.IsApproved, null, currentCom.id.ToString(), out status); if (status != "Success") { AccountModel model = new AccountModel(); Messages.AddErrorMessage("Tài khoản đã có trên hệ thống hoặc dữ liệu không hợp lệ."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = temp.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = UserRoles ?? new string[] { }; model.UserTmp = temp; return(View("Create", model)); } _RoleProvider.UpdateUsersToRoles(u.userid, UserRoles); Messages.AddFlashMessage(Resources.Message.User_UMesSuccess); log.Info("Create Account:" + HttpContext.User.Identity.Name + ", Date: " + DateTime.Now); Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; IStaffService _staSrv = IoC.Resolve <IStaffService>(); Staff newStaff = new Staff { FullName = fullname, AccountName = u.username, ComID = currentComp.id, Email = u.email }; _staSrv.CreateNew(newStaff); _staSrv.CommitChanges(); return(RedirectToAction("Index")); } catch (Exception ex) { log.Error("Create Error:", ex); AccountModel model = new AccountModel(); Messages.AddErrorMessage("Tài khoản đã có trên hệ thống hoặc dữ liệu không hợp lệ."); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = temp.password = ""; model.AllRoles = lst.ToArray(); model.UserRoles = new string[] { }; model.UserTmp = temp; return(View("Create", model)); } }
public ActionResult Update(int id, string RetypePassword, string[] UserRoles, string fullname) { if (id <= 0) { throw new HttpRequestValidationException(); } IRBACMembershipProvider _MemberShipProvider = IoC.Resolve <IRBACMembershipProvider>(); IRBACRoleProvider _RoleProvider = IoC.Resolve <IRBACRoleProvider>(); user Ouser = _MemberShipProvider.GetUser(id, false); if (HttpContext.User.Identity.Name == Ouser.username) { Messages.AddErrorFlashMessage(Resources.Message.User_UMesCantEdit); return(RedirectToAction("index")); } //lay doi tuong tai khoan cu string OldPassword = Ouser.password; string Oldusername = Ouser.username; AccountModel model = new AccountModel(); try { TryUpdateModel <user>(Ouser); if (Ouser.password != RetypePassword) { Messages.AddErrorMessage(Resources.Message.User_MesConfirmPass); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = Ouser.password = OldPassword; model.AllRoles = lst.ToArray(); model.UserRoles = _RoleProvider.GetRolesForUser(Ouser.userid); model.UserTmp = Ouser; return(View("Edit", model)); } if (Ouser.password != OldPassword) { Ouser.PasswordSalt = GeneratorPassword.GenerateSalt(); Ouser.password = GeneratorPassword.EncodePassword(Ouser.password, Ouser.PasswordFormat, Ouser.PasswordSalt);//FormsAuthentication.HashPasswordForStoringInConfigFile(RetypePassword, "MD5"); } Ouser.FailedPasswordAttemptCount = 0; //update lai tai khoan _MemberShipProvider.UpdateUser(Ouser); model.UserRoles = UserRoles ?? new string[] { }; _RoleProvider.UpdateUsersToRoles(Ouser.userid, model.UserRoles); Messages.AddFlashMessage(Resources.Message.User_UMesSuccess); log.Info("Update Account:" + HttpContext.User.Identity.Name + ", Date: " + DateTime.Now); Company currentComp = ((EInvoiceContext)FXContext.Current).CurrentCompany; IStaffService _staSrv = IoC.Resolve <IStaffService>(); Staff sta = _staSrv.SearchByAccountName(Ouser.username, currentComp.id); sta.FullName = fullname; _staSrv.UpdateStaff(sta); return(RedirectToAction("index")); } catch (Exception ex) { log.Error("Error Update:", ex); Messages.AddErrorMessage("Có lỗi xảy ra, vui lòng thực hiện lại!"); List <String> lst = new List <string>(_RoleProvider.GetAllRoles()); if (lst.IndexOf("ServiceRole") >= 0) { lst.RemoveAt(lst.IndexOf("ServiceRole")); } if (lst.IndexOf("Root") >= 0) { lst.RemoveAt(lst.IndexOf("Root")); } model.RetypePassword = Ouser.password = OldPassword; model.AllRoles = lst.ToArray(); model.UserRoles = _RoleProvider.GetRolesForUser(Ouser.userid); model.UserTmp = Ouser; return(View("Edit", model)); } }