public async Task <IEnumerable <RoleEntity> > RolesAsync() { using var connection = _strongHoldDataBase.Get(); const string sql = "select * from dbo.Role where id != '00000000-0000-0000-0000-000000000000'"; return(await connection.QueryAsync <RoleEntity>(sql)); }
public async Task HandleAsync(CreateRole command, CorrelationContext context) { using (var connection = _strongHoldDataBase.Get()) { const string sql = @" INSERT INTO [dbo].[Role] ([id], [parentId], [name], [description], [roleContextId], [created], [createdBy], [modified], [modifiedBy]) VALUES (@id, @parentId, @name, @description, @roleContextId, @created, @createdBy, @modified, @modifiedBy)"; await connection.ExecuteAsync(sql, new { id = command.Id, parentId = command.ParentId.IfEmptyThenEmptyId(), name = command.Name, description = command.Description, roleContextId = command.RoleContextId.IfEmptyThenEmptyId(), created = DateTime.UtcNow.GetUxTime(), createdBy = context.UserId, modified = DateTime.UtcNow.GetUxTime(), modifiedBy = context.UserId }); } _logger.LogInformation($"Creating role {command.Id} - {command.Name}"); await _busPublisher.PublishAsync(new RoleCreated { Id = command.Id, Name = command.Name }, context); }