Cleaning up with Rider
This commit is contained in:
parent
69758735de
commit
91da89a4e8
22 changed files with 574 additions and 386 deletions
|
|
@ -12,37 +12,27 @@ namespace PlanTempus.Components.Organizations.Create
|
|||
_databaseOperations = databaseOperations;
|
||||
}
|
||||
|
||||
public async Task<CreateOrganizationResponse> Handle(CreateOrganizationCommand command)
|
||||
public async Task<CreateOrganizationResult> Handle(CreateOrganizationCommand command)
|
||||
{
|
||||
using var db = _databaseOperations.CreateScope(nameof(CreateOrganizationHandler));
|
||||
|
||||
try
|
||||
{
|
||||
var organizationId = Guid.NewGuid();
|
||||
var now = DateTime.UtcNow;
|
||||
|
||||
var sql = @"
|
||||
INSERT INTO organizations (id, name, description, created_by_id)
|
||||
VALUES (@Id, @Name, @Description, @CreatedById)";
|
||||
var sql = @"
|
||||
INSERT INTO organizations (connection_string, created_by)
|
||||
VALUES (@ConnectionString, @CreatedBy)
|
||||
RETURNING id, created_at";
|
||||
|
||||
|
||||
await db.Connection.ExecuteSqlAsync(sql, new
|
||||
var data = await db.Connection.QuerySqlAsync<CreateOrganizationResult>(sql, new
|
||||
{
|
||||
Id = organizationId,
|
||||
command.Name,
|
||||
command.Description,
|
||||
CreatedById = command.CreatedById,
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
ConnectionString = command.ConnectionString,
|
||||
CreatedBy = command.CreatedById
|
||||
});
|
||||
|
||||
db.Success();
|
||||
|
||||
return new CreateOrganizationResponse
|
||||
{
|
||||
Id = organizationId,
|
||||
Name = command.Name,
|
||||
CreatedAt = now
|
||||
};
|
||||
return data.First();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue