-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(samples): update helpdesk as web api
- Loading branch information
Showing
47 changed files
with
809 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/.idea | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
**/.github | ||
**/.idea* | ||
**/artifacts | ||
LICENSE | ||
README.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
version: "3" | ||
services: | ||
helpdesk-relational-app: | ||
image: raiqub.samples.helpdesk-relational | ||
build: | ||
context: . | ||
dockerfile: samples/Helpdesk.Relational/Dockerfile | ||
ports: | ||
- "8080:80" | ||
environment: | ||
ASPNETCORE_ENVIRONMENT: Development | ||
depends_on: | ||
- helpdesk-relational-db | ||
- helpdesk-relational-pgadmin | ||
|
||
helpdesk-relational-db: | ||
image: clkao/postgres-plv8 | ||
environment: | ||
POSTGRES_PASSWORD: Password12! | ||
|
||
helpdesk-relational-pgadmin: | ||
image: dpage/pgadmin4 | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} | ||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} | ||
PGADMIN_CONFIG_SERVER_MODE: 'False' | ||
volumes: | ||
- pgadmin:/var/lib/pgadmin | ||
ports: | ||
- "${PGADMIN_PORT:-5050}:80" | ||
depends_on: | ||
- helpdesk-relational-db | ||
|
||
volumes: | ||
pgadmin: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS base | ||
WORKDIR /app | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
|
||
FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build | ||
WORKDIR /src | ||
COPY . . | ||
WORKDIR "/src/samples/Helpdesk.Relational" | ||
RUN dotnet restore | ||
RUN dotnet build "Helpdesk.Relational.csproj" -c Release -o /app/build | ||
|
||
FROM build AS publish | ||
RUN dotnet publish "Helpdesk.Relational.csproj" -c Release -o /app/publish /p:UseAppHost=false | ||
|
||
FROM base AS final | ||
WORKDIR /app | ||
COPY --from=publish /app/publish . | ||
ENTRYPOINT ["dotnet", "Raiqub.Helpdesk.Relational.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<IsPackable>false</IsPackable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\src\Expressions.Writing\Expressions.Writing.csproj" /> | ||
<ProjectReference Include="..\..\src\Expressions.EntityFrameworkCore\Expressions.EntityFrameworkCore.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="6.0.8" /> | ||
<PackageReference Include="RT.Comb" Version="4.0.1" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" /> | ||
<PackageReference Include="System.Linq.Async" Version="6.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using Helpdesk.Relational.Incidents; | ||
using Helpdesk.Relational.Incidents.Categorise; | ||
using Helpdesk.Relational.Incidents.LogNew; | ||
using Helpdesk.Relational.Incidents.Prioritise; | ||
using Microsoft.EntityFrameworkCore; | ||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion; | ||
|
||
namespace Helpdesk.Relational; | ||
|
||
public class HelpdeskDbContext : DbContext | ||
{ | ||
public HelpdeskDbContext(DbContextOptions<HelpdeskDbContext> options) : base(options) | ||
{ | ||
} | ||
|
||
protected override void OnModelCreating(ModelBuilder modelBuilder) | ||
{ | ||
var incidentBuilder = modelBuilder.Entity<Incident>(); | ||
|
||
incidentBuilder.Property(i => i.Id); | ||
incidentBuilder.Property(i => i.CustomerId); | ||
incidentBuilder.Property(i => i.Description); | ||
incidentBuilder.Property(i => i.LoggedBy); | ||
incidentBuilder.Property(i => i.LoggedAt); | ||
incidentBuilder.Property(i => i.Status).HasConversion<EnumToStringConverter<IncidentStatus>>(); | ||
incidentBuilder.Property(i => i.Category).HasConversion<EnumToStringConverter<IncidentCategory>>(); | ||
incidentBuilder.Property(i => i.Priority).HasConversion<EnumToStringConverter<IncidentPriority>>(); | ||
incidentBuilder.HasKey(i => i.Id); | ||
|
||
incidentBuilder.OwnsOne(i => i.Contact) | ||
.Property(c => c.ContactChannel).HasConversion<EnumToStringConverter<ContactChannel>>(); | ||
incidentBuilder.HasMany(i => i.Responses).WithOne(); | ||
|
||
incidentBuilder.Navigation(i => i.Responses).AutoInclude(); | ||
|
||
var responseBuilder = modelBuilder.Entity<IncidentResponse>(); | ||
responseBuilder.Property<int>("Id"); | ||
responseBuilder.HasKey("Id"); | ||
|
||
responseBuilder.HasDiscriminator<string>("type") | ||
.HasValue<IncidentResponse.FromAgent>("agent") | ||
.HasValue<IncidentResponse.FromCustomer>("customer"); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...cidents/Acknowledge/AcknowledgeHandler.cs → ...idents/Acknowledge/AcknowledgeScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/Helpdesk.Relational/Incidents/Acknowledge/v1/AcknowledgeIncidentResolutionUseCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Raiqub.Expressions.Sessions; | ||
|
||
namespace Helpdesk.Relational.Incidents.Acknowledge.v1; | ||
|
||
public class AcknowledgeIncidentResolutionUseCase | ||
{ | ||
private readonly IDbSession _dbSession; | ||
|
||
public AcknowledgeIncidentResolutionUseCase(IDbSession dbSession) | ||
{ | ||
_dbSession = dbSession; | ||
} | ||
|
||
public async Task Execute(Guid incidentId, Guid customerId, CancellationToken cancellationToken) | ||
{ | ||
var incident = await _dbSession.Query(IncidentSpecification.HasId(incidentId)).FirstAsync(cancellationToken); | ||
incident.Apply(AcknowledgeScenario.Execute(incident, new AcknowledgeResolution(incidentId, customerId))); | ||
|
||
_dbSession.Update(incident); | ||
await _dbSession.SaveChangesAsync(cancellationToken); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
.../Helpdesk.Relational/Incidents/Api/v1/GetAllOfCustomer/GetAllOfCustomerIncidentHandler.cs
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
.../Helpdesk.Relational/Incidents/Api/v1/GetAllOfCustomer/GetAllOfCustomerIncidentRequest.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/Helpdesk.Relational/Incidents/AssignAgent/v1/AssignAgentToIncidentUseCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Raiqub.Expressions.Sessions; | ||
|
||
namespace Helpdesk.Relational.Incidents.AssignAgent.v1; | ||
|
||
public class AssignAgentToIncidentUseCase | ||
{ | ||
private readonly IDbSession _dbSession; | ||
|
||
public AssignAgentToIncidentUseCase(IDbSession dbSession) | ||
{ | ||
_dbSession = dbSession; | ||
} | ||
|
||
public async Task Execute(Guid incidentId, Guid agentId, CancellationToken cancellationToken) | ||
{ | ||
var incident = await _dbSession.Query(IncidentSpecification.HasId(incidentId)).FirstAsync(cancellationToken); | ||
incident.Apply(AssignAgentScenario.Execute(incident, new AssignAgentToIncident(incidentId, agentId))); | ||
|
||
_dbSession.Update(incident); | ||
await _dbSession.SaveChangesAsync(cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
samples/Helpdesk.Relational/Incidents/Categorise/v1/CategoriseIncidentRequest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Helpdesk.Relational.Incidents.Categorise.v1; | ||
|
||
public record CategoriseIncidentRequest(IncidentCategory Category); |
27 changes: 27 additions & 0 deletions
27
samples/Helpdesk.Relational/Incidents/Categorise/v1/CategoriseIncidentUseCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Raiqub.Expressions.Sessions; | ||
|
||
namespace Helpdesk.Relational.Incidents.Categorise.v1; | ||
|
||
public class CategoriseIncidentUseCase | ||
{ | ||
private readonly IDbSession _dbSession; | ||
|
||
public CategoriseIncidentUseCase(IDbSession dbSession) | ||
{ | ||
_dbSession = dbSession; | ||
} | ||
|
||
public async Task Execute( | ||
Guid incidentId, | ||
Guid agentId, | ||
CategoriseIncidentRequest request, | ||
CancellationToken cancellationToken) | ||
{ | ||
var incident = await _dbSession.Query(IncidentSpecification.HasId(incidentId)).FirstAsync(cancellationToken); | ||
incident.Apply( | ||
CategoriseScenario.Execute(incident, new CategoriseIncident(incidentId, request.Category, agentId))); | ||
|
||
_dbSession.Update(incident); | ||
await _dbSession.SaveChangesAsync(cancellationToken); | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...elational/Incidents/Close/CloseHandler.cs → ...lational/Incidents/Close/CloseScenario.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/Helpdesk.Relational/Incidents/Close/v1/CloseIncidentUseCase.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Raiqub.Expressions.Sessions; | ||
|
||
namespace Helpdesk.Relational.Incidents.Close.v1; | ||
|
||
public class CloseIncidentUseCase | ||
{ | ||
private readonly IDbSession _dbSession; | ||
|
||
public CloseIncidentUseCase(IDbSession dbSession) | ||
{ | ||
_dbSession = dbSession; | ||
} | ||
|
||
public async Task Execute(Guid incidentId, Guid agentId, CancellationToken cancellationToken) | ||
{ | ||
var incident = await _dbSession.Query(IncidentSpecification.HasId(incidentId)).FirstAsync(cancellationToken); | ||
incident.Apply(CloseScenario.Execute(incident, new CloseIncident(incidentId, agentId))); | ||
|
||
_dbSession.Update(incident); | ||
await _dbSession.SaveChangesAsync(cancellationToken); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
samples/Helpdesk.Relational/Incidents/GetCustomerSummary/CustomerIncidentsSummary.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Helpdesk.Relational.Incidents.GetCustomerSummary; | ||
|
||
public record CustomerIncidentsSummary(Guid Id) | ||
{ | ||
public int Pending { get; init; } | ||
public int Resolved { get; init; } | ||
public int Acknowledged { get; init; } | ||
public int Closed { get; init; } | ||
} |
19 changes: 19 additions & 0 deletions
19
...Helpdesk.Relational/Incidents/GetCustomerSummary/GetCustomerIncidentsSummaryQueryModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using Raiqub.Expressions.Queries; | ||
|
||
namespace Helpdesk.Relational.Incidents.GetCustomerSummary; | ||
|
||
public class GetCustomerIncidentsSummaryQueryModel : IQueryModel<(IncidentStatus Key, int Count)> | ||
{ | ||
public GetCustomerIncidentsSummaryQueryModel(Guid customerId) => CustomerId = customerId; | ||
|
||
public Guid CustomerId { get; } | ||
|
||
public IQueryable<(IncidentStatus Key, int Count)> Execute(IQuerySource source) | ||
{ | ||
return from pending in source.GetSet<Incident>() | ||
where pending.CustomerId == CustomerId | ||
group pending by pending.Status | ||
into g | ||
select new ValueTuple<IncidentStatus, int>(g.Key, g.Count()); | ||
} | ||
} |
Oops, something went wrong.