Esempio n. 1
0
        /// <summary>
        /// 创建角色
        /// </summary>
        /// <param name="request">创建请求参数</param>
        public async Task <Guid> CreateAsync(CreateRoleRequest request)
        {
            var role = ToEntity(request);

            role.Type = "Role";
            await RoleManager.CreateAsync(role);

            await MessageEventBus.PublishAsync(new CreateRoleMessageEvent(
                                                   new CreateRoleMessage()
            {
                Code = $"event:{role.Code}",
                Name = $"event:{role.Name}",
                Type = $"event:{role.Type}"
            }));

            await SqlExecutor.ExecuteSqlAsync("insert into Systems.Test(Id, Name) Values(@Id, @Name)",
                                              new { Id = Guid.NewGuid(), Name = "隔壁老王" });

            await UnitOfWork.CommitAsync();

            return(role.Id);
        }