public ActionResult GetUserListJson(string postId) { var existMember = permissionBLL.GetMemberList(postId); var userData = userBLL.GetDepartmentUserList(); List <DepartmentUserModel> userList = new List <DepartmentUserModel>(); foreach (UserEntity userItem in userData) { DepartmentUserModel model = new DepartmentUserModel(); int ischeck = existMember.Count(t => t.UserId == userItem.UserId); model.ischeck = ischeck; if (ischeck > 0) { model.isdefault = existMember.First(t => t.UserId == userItem.UserId).IsDefault; } else { model.isdefault = 0; } model.gender = userItem.Gender; model.departmentid = userItem.DepartmentId; model.departmentname = departmentCache.GetEntity(model.departmentid) != null?departmentCache.GetEntity(model.departmentid).FullName : ""; model.realname = userItem.RealName; model.account = userItem.Account; model.userid = userItem.UserId; userList.Add(model); } return(Content(userList.ToJson())); }
public ActionResult Add(UserModel model) { model.CreateOn = DateTime.Now; model.CreateBy = Operator.UserId; model.PassWord = Md5.md5(Configs.GetValue("InitUserPwd"), 32); var userId = userService.CreateModelReturnId(model); if (userId > 0) { var departmentUser = new DepartmentUserModel() { DepartmentId = model.DepartmentId, UserId = userId }; if (departmentUserService.CreateModel(departmentUser)) { return(Json(SuccessTip())); } else { userService.DeleteModel(userId); return(Json(ErrorTip())); } } else { return(Json(ErrorTip())); } }