public ActionResult SetRole(AjaxEmployee model) { if (ModelState.IsValid) { var s = CH.GetDataById <EmployeeRole>(model.ID); s.IsActivated = model.IsActivated; s.RoleID = model.RoleID; s.ExpLevelID = model.ExpLevelID; s.StartDate = model.StartDate; s.IsTrainee = model.IsTrainee; //MembershipUser user = Membership.GetUser(s.AccountName); ProfileBase objProfile = ProfileBase.Create(s.AccountName); objProfile.SetPropertyValue("IsActivated", model.IsActivated); objProfile.Save(); CH.Edit <EmployeeRole>(s); return(Json("")); } else { string error = ""; foreach (var key in ModelState.Keys) { var state = ModelState[key]; if (state.Errors.Any()) { error += state.Errors.First().ErrorMessage + ","; } } return(Json(error.Substring(0, error.Length - 1))); } }
public ActionResult AccountInfo(AjaxEmployee model) { if (model.AccountName == null) { return(Json("")); } if (ModelState.IsValid) { var s = CH.GetDataById <EmployeeRole>(model.ID); s.AgentNum = model.AgentNum; s.Gender = model.Gender; s.Email = model.Email; s.BirthDay = model.BirthDay; s.DepartmentID = model.DepartmentID; s.Mobile = model.Mobile; s.EmailSignatures = model.EmailSignatures; s.AccountNameCN = model.AccountNameCN; if (!string.IsNullOrWhiteSpace(model.EmailPassword)) { s.EmailPassword = model.EmailPassword; //if (GetMD5Hash(model.OldPassword) != s.EmailPassword) //{ // return Json("初始密码错误!"); //} } //s.EmailPassword = GetMD5Hash(model.EmailPassword); CH.Edit <EmployeeRole>(s); return(Json("")); } else { string error = ""; foreach (var key in ModelState.Keys) { var state = ModelState[key]; if (state.Errors.Any()) { error += state.Errors.First().ErrorMessage + ","; } } return(Json(error.Substring(0, error.Length - 1))); } }