public ExcuteResultEnum AddNewBcUserRole(BcUserRoleEntity entity)
 {
     if (EntityExecution.GetEntityCount2<BcUserRoleEntity>(n => n.RoleId == entity.RoleId && n.UserId == entity.UserId) > 0)
         return ExcuteResultEnum.IsExist;
     EntityExecution.InsertEntity(entity);
     return ExcuteResultEnum.Success;
 }
 private BcUserRoleEntity PrepareFormData()
 {
     this.ddlUser.SelectedValue.InitValidation("用户").NotEmpty();
     this.ddlRole.SelectedValue.InitValidation("角色").NotEmpty();
     var entity = new BcUserRoleEntity();
     entity.UserId = int.Parse(this.ddlUser.SelectedValue);
     entity.RoleId = int.Parse(this.ddlRole.SelectedValue);
     return entity;
 }
        public ExcuteResultEnum AddNewBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
        {
            if (EntityExecution.GetEntityCount2<BcUserInfoEntity>(n => n.UserAccount == entity.UserAccount && n.DeleteFlag == false) > 0)
                return ExcuteResultEnum.IsExist;

            using (TransactionScope ts = new TransactionScope())
            {
                entity.UserId = null;
                entity.DeleteFlag = false;
                entity.Password = Encryption.Encrypt(entity.Password);
                var id = EntityExecution.InsertEntityWithIdentity(entity);
                if (!string.IsNullOrEmpty(roleIds))
                {
                    foreach (string roleId in roleIds.Split(','))
                    {
                        var userRoleEntity = new BcUserRoleEntity { UserId = (int?)id, RoleId = int.Parse(roleId) };
                        EntityExecution.InsertEntity(userRoleEntity);
                    }
                }
                ts.Complete();
            }
            return ExcuteResultEnum.Success;
        }
 public ExcuteResultEnum UpdateBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
 {
     entity.Password = Encryption.Encrypt(entity.Password);
     using (TransactionScope ts = new TransactionScope())
     {
         EntityExecution.UpdateEntity(entity);
         EntityExecution.DeleteEntity2<BcUserRoleEntity>(n => n.UserId == entity.UserId);
         if (!string.IsNullOrEmpty(roleIds))
         {
             foreach (string roleId in roleIds.Split(','))
             {
                 var userRoleEntity = new BcUserRoleEntity
                 {
                     UserId = entity.UserId,
                     RoleId = int.Parse(roleId)
                 };
                 EntityExecution.InsertEntity(userRoleEntity);
             }
         }
         ts.Complete();
     }
     return ExcuteResultEnum.Success;
 }
 public void UpdateBcUserRole(BcUserRoleEntity entity) { EntityExecution.UpdateEntity(entity); }
 public void DeleteBcUserRole(int userId, int roleId)
 {
     BcUserRoleEntity entity = new BcUserRoleEntity() { UserId = userId, RoleId = roleId };
     EntityExecution.DeleteEntity(entity);
 }