public APIJsonResult Add(AdminUserRegModel adminUserModel) { var adminUserBLL = new TAdminUserBLL(); var adminUser = new TAdminUser() { Account = adminUserModel.Account.Trim(), Password = EncryptHelper.EncryptString(adminUserModel.Password), Status = adminUserModel.Status }; AddCreateInfo(adminUser); var role = new TAdminUserRole() { RoleID = adminUserModel.RoleID }; AddCreateInfo(role); try { adminUserBLL.Register(adminUser, role); } catch (ValidationException ex) { return(Failed(ex.Message)); } return(Success()); }
//public new List<TAdminUser> PagerQuery<Tkey>(int pageSize, int pageIndex, out int total, Expression<Func<TAdminUser, bool>> whereLambda, Func<TAdminUser, Tkey> orderbyLambda, bool isAsc) //{ // var adminUserList bdal.PagerQuery(pageSize, pageIndex, out total, whereLambda, orderbyLambda, isAsc); //} public void Register(TAdminUser userModel, TAdminUserRole roleModel) { var existAccount = Find(u => u.Account == userModel.Account); if (existAccount != null) { throw new ValidationException("Account name duplicated."); } Add(userModel); SaveChanges(); roleModel.AdminUserID = userModel.ID; var roleBLL = new TAdminUserRoleBLL(); roleBLL.Add(roleModel); roleBLL.SaveChanges(); }