Various work around the architecture
This commit is contained in:
parent
b1e134490d
commit
71576a4b1f
18 changed files with 522 additions and 358 deletions
7
PlanTempus.Components/Class1.cs
Normal file
7
PlanTempus.Components/Class1.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
namespace PlanTempus.Components
|
||||
{
|
||||
public class Class1
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
namespace PlanTempus.Components.Organizations.Create
|
||||
{
|
||||
public class CreateOrganizationCommand
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public Guid CreatedById { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
using Insight.Database;
|
||||
|
||||
namespace PlanTempus.Components.Organizations.Create
|
||||
{
|
||||
public class CreateOrganizationHandler
|
||||
{
|
||||
private readonly IDatabaseOperations _databaseOperations;
|
||||
|
||||
public CreateOrganizationHandler(IDatabaseOperations databaseOperations)
|
||||
{
|
||||
_databaseOperations = databaseOperations;
|
||||
}
|
||||
|
||||
public async Task<CreateOrganizationResponse> 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, CreatedById, CreatedAt, UpdatedAt)
|
||||
VALUES (@Id, @Name, @Description, @CreatedById, @CreatedAt, @UpdatedAt)";
|
||||
|
||||
await db.Connection.ExecuteSqlAsync(sql, new
|
||||
{
|
||||
Id = organizationId,
|
||||
command.Name,
|
||||
command.Description,
|
||||
CreatedById = command.CreatedById,
|
||||
CreatedAt = now,
|
||||
UpdatedAt = now
|
||||
});
|
||||
|
||||
db.Success();
|
||||
|
||||
return new CreateOrganizationResponse
|
||||
{
|
||||
Id = organizationId,
|
||||
Name = command.Name,
|
||||
CreatedAt = now
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
db.Error(ex);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
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; }
|
||||
}
|
||||
}
|
||||
17
PlanTempus.Components/PlanTempus.Components.csproj
Normal file
17
PlanTempus.Components/PlanTempus.Components.csproj
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Core\PlanTempus.Core.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Organizations\Delete\" />
|
||||
<Folder Include="Organizations\Update\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Loading…
Add table
Add a link
Reference in a new issue