Cleaning up with Rider
This commit is contained in:
parent
69758735de
commit
91da89a4e8
22 changed files with 574 additions and 386 deletions
|
|
@ -3,7 +3,7 @@
|
|||
public class CreateOrganizationCommand
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public string ConnectionString { get; set; }
|
||||
public Guid CreatedById { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,15 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace PlanTempus.Components.Organizations.Create
|
||||
{
|
||||
public class CreateOrganizationResponse
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
namespace PlanTempus.Components.Organizations.Create
|
||||
{
|
||||
public class CreateOrganizationResult
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue