Esempio n. 1
0
            public override async Task <int> Handle(AdminUserCreateCommand request, CancellationToken cancellationToken)
            {
                //await bus.PublishEvent(new DomainNotification("", "开始注册...."), cancellationToken);

                var entity = mapper.Map <AdminUserCreateCommand, AdminUserEntity>(request);

                //角色操作
                if (request.Roles != null && request.Roles.Length > 0)
                {
                    //转换角色对象 并写入
                    entity.UserRoles = Array.ConvertAll(request.Roles, roleid => new AdminUserRoleEntity
                    {
                        RoleId  = roleid,
                        AdminId = entity.Id
                    });
                }

                var res = db.Add(entity);

                //await bus.PublishEvent(new DomainNotification("", "结束注册...."), cancellationToken);

                if (res > 0)
                {
                    await bus.PublishEvent(new CreateEvent(entity.Id, entity), cancellationToken);

                    return(res);
                }
                else
                {
                    return(res);
                }
            }
Esempio n. 2
0
            public override async Task <int> Handle(AdminRoleCreateCommand request, CancellationToken cancellationToken)
            {
                var entity = mapper.Map <AdminRoleCreateCommand, AdminRoleEntity>(request);

                //保存关联导航
                if (request.MenuIds != null && request.MenuIds.Length > 0)
                {
                    entity.RoleMenus = Array.ConvertAll(request.MenuIds, key => new AdminRoleMenuEntity
                    {
                        RoleId = entity.Id,
                        MenuId = key
                    });
                }

                var res = db.Add(entity);

                if (res > 0)
                {
                    await bus.PublishEvent(new CreateEvent(entity.Id, entity), cancellationToken);

                    return(res);
                }
                else
                {
                    return(res);
                }
            }
Esempio n. 3
0
            public override async Task <int> Handle(AdminUserCreateCommand request, CancellationToken cancellationToken)
            {
                //await bus.PublishEvent(new DomainNotification("", "开始注册...."), cancellationToken);

                var entity = mapper.Map <AdminUserCreateCommand, AdminUserEntity>(request);

                var res = db.Add(entity);

                //await bus.PublishEvent(new DomainNotification("", "结束注册...."), cancellationToken);

                if (res > 0)
                {
                    await bus.PublishEvent(new CreateEvent(entity.Id, entity), cancellationToken);
                }

                return(res);
            }
Esempio n. 4
0
            public override async Task <int> Handle(AdminMenuCreateCommand request, CancellationToken cancellationToken)
            {
                var entity = mapper.Map <AdminMenuCreateCommand, AdminMenuEntity>(request);

                var res = db.Add(entity);

                if (res > 0)
                {
                    await bus.PublishEvent(new CreateEvent(entity.Id, entity), cancellationToken);

                    return(res);
                }
                else
                {
                    return(res);
                }
            }