Ejemplo n.º 1
0
 public ExcuteResultEnum AddNewBcUserRole(BcUserRoleEntity entity)
 {
     if (EntityExecution.Count<BcUserRoleEntity>(n => n.RoleId == entity.RoleId && n.UserId == entity.UserId) > 0)
         return ExcuteResultEnum.IsExist;
     entity.Insert();
     return ExcuteResultEnum.Success;
 }
Ejemplo n.º 2
0
        public ExcuteResultEnum AddNewBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
        {
            if (
                EntityExecution.Count<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.InsertWithIdentity(entity);
                if (!string.IsNullOrEmpty(roleIds))
                {
                    foreach (string roleId in roleIds.Split(','))
                    {
                        var userRoleEntity = new BcUserRoleEntity {UserId = (int?) id, RoleId = int.Parse(roleId)};
                        EntityExecution.Insert(userRoleEntity);
                    }
                }
                ts.Complete();
            }
            return ExcuteResultEnum.Success;
        }
Ejemplo n.º 3
0
 private BcUserRoleEntity PrepareFormData()
 {
     ddlUser.SelectedValue.InitValidation("用户").NotEmpty();
     ddlRole.SelectedValue.InitValidation("角色").NotEmpty();
     var entity = new BcUserRoleEntity();
     entity.UserId = int.Parse(ddlUser.SelectedValue);
     entity.RoleId = int.Parse(ddlRole.SelectedValue);
     return entity;
 }
Ejemplo n.º 4
0
 public ExcuteResultEnum UpdateBcUserInfo(BcUserInfoEntity entity, string roleIds = null)
 {
     entity.Password = Encryption.Encrypt(entity.Password);
     using (TransactionScope ts = new TransactionScope())
     {
         entity.Update();
         EntityExecution.Delete<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.Insert(userRoleEntity);
             }
         }
         ts.Complete();
     }
     return ExcuteResultEnum.Success;
 }
Ejemplo n.º 5
0
 public void UpdateBcUserRole(BcUserRoleEntity entity)
 {
     entity.Update();
 }
Ejemplo n.º 6
0
 public void DeleteBcUserRole(int userId, int roleId)
 {
     BcUserRoleEntity entity = new BcUserRoleEntity() {UserId = userId, RoleId = roleId};
     EntityExecution.Delete(entity);
 }