Compare commits
20 Commits
f116d6702f
...
7fea71c08d
| Author | SHA1 | Date | |
|---|---|---|---|
| 7fea71c08d | |||
| b42dcc37ad | |||
| 89d0e6a38a | |||
| 4688883f2e | |||
| 67b2456032 | |||
| 3b9b9f19b2 | |||
| dec10eeb79 | |||
| 816b72bfc8 | |||
| 2fbd50d52e | |||
| cf8f9d76e3 | |||
| 3377cc6121 | |||
| 2c73022526 | |||
| 1699cca53d | |||
| fd6e6d474d | |||
| 1e1ead5c49 | |||
| 89ace0de42 | |||
| bb5c8d7ad2 | |||
| c74f5a9035 | |||
| eeccbfb81a | |||
| c9a026577a |
43
Leanetec.EConnect.sln
Normal file
43
Leanetec.EConnect.sln
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.14.36221.1
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Leanetec.EConnect.Domain", "src\Leanetec.EConnect.Domain\Leanetec.EConnect.Domain.csproj", "{34DC964A-1905-7DFC-0125-D551D3EEFCDD}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Leanetec.EConnect.Client", "src\Leanetec.EConnect.Client\Leanetec.EConnect.Client.csproj", "{9242EEA9-447B-44A6-A66D-D671DD16D0BB}"
|
||||
EndProject
|
||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "docs", "docs", "{AC628874-E7B7-4CA6-8614-03DCCC9DE5CA}"
|
||||
ProjectSection(SolutionItems) = preProject
|
||||
docs\econnect-api_swagger.json = docs\econnect-api_swagger.json
|
||||
docs\econnect-api_swagger.pdf = docs\econnect-api_swagger.pdf
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{34DC964A-1905-7DFC-0125-D551D3EEFCDD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{34DC964A-1905-7DFC-0125-D551D3EEFCDD}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{34DC964A-1905-7DFC-0125-D551D3EEFCDD}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{34DC964A-1905-7DFC-0125-D551D3EEFCDD}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9242EEA9-447B-44A6-A66D-D671DD16D0BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(NestedProjects) = preSolution
|
||||
{34DC964A-1905-7DFC-0125-D551D3EEFCDD} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
{9242EEA9-447B-44A6-A66D-D671DD16D0BB} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {8C81AD6F-B903-4C78-873C-38EE216EFAD5}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
4309
docs/econnect-api_swagger.json
Normal file
4309
docs/econnect-api_swagger.json
Normal file
File diff suppressed because it is too large
Load Diff
BIN
docs/econnect-api_swagger.pdf
Normal file
BIN
docs/econnect-api_swagger.pdf
Normal file
Binary file not shown.
22
src/Leanetec.EConnect.Client/Alive/GetRequest.cs
Normal file
22
src/Leanetec.EConnect.Client/Alive/GetRequest.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Leanetec.EConnect.Client.Models;
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Alive;
|
||||
|
||||
public enum Role
|
||||
{
|
||||
User,
|
||||
Admin
|
||||
}
|
||||
|
||||
public record GetRequest(Role? Role = null) : Request<bool>, IRequest<bool>
|
||||
{
|
||||
}
|
||||
|
||||
public class GetRequestHandler : IRequestHandler<GetRequest, bool>
|
||||
{
|
||||
public Task<bool> Handle(GetRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Alive/MediatRExtensions.cs
Normal file
17
src/Leanetec.EConnect.Client/Alive/MediatRExtensions.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Alive;
|
||||
|
||||
public static class MediatRExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns true if while the application is up.
|
||||
/// </summary>
|
||||
/// <param name="mediator"></param>
|
||||
/// <param name="role">Role of logged user</param>
|
||||
/// <returns></returns>
|
||||
public static Task<bool> IsAliveAsync(this IMediator mediator, Role? role = null, int? apiVersion = null) => mediator.Send(new GetRequest(role)
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
});
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Articles/GetRequest.cs
Normal file
17
src/Leanetec.EConnect.Client/Articles/GetRequest.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Leanetec.EConnect.Client.Models;
|
||||
using Leanetec.EConnect.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Articles;
|
||||
|
||||
public record GetRequest(int? ArticleId = null) : Request<IEnumerable<Article>>, IRequest<IEnumerable<Article>>
|
||||
{
|
||||
}
|
||||
|
||||
public class GetRequestHandler : IRequestHandler<GetRequest, IEnumerable<Article>>
|
||||
{
|
||||
public Task<IEnumerable<Article>> Handle(GetRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
60
src/Leanetec.EConnect.Client/Articles/MediatRExtensions.cs
Normal file
60
src/Leanetec.EConnect.Client/Articles/MediatRExtensions.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using Leanetec.EConnect.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Articles;
|
||||
|
||||
/// <summary>
|
||||
/// Extension methods for the <see cref="IMediator"/> interface to simplify working with <see cref="Article"/> entities.
|
||||
/// </summary>
|
||||
public static class MediatRExtensions
|
||||
{
|
||||
#region GetRequest
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves a single <see cref="Article"/> by its unique identifier.
|
||||
/// </summary>
|
||||
/// <param name="mediator">The <see cref="IMediator"/> instance used to send the request.</param>
|
||||
/// <param name="id">The unique identifier of the article to retrieve.</param>
|
||||
/// <param name="apiVersion">Optional API version to target the request.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation. The task result contains the matching <see cref="Article"/>, or <c>null</c> if not found.
|
||||
/// </returns>
|
||||
public static async Task<Article?> GetArticleByIdAsync(this IMediator mediator, int id, int? apiVersion = null)
|
||||
{
|
||||
var articles = await mediator.Send(new GetRequest(id) { ApiVersion = apiVersion });
|
||||
return articles.FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves all available <see cref="Article"/> entities.
|
||||
/// </summary>
|
||||
/// <param name="mediator">The <see cref="IMediator"/> instance used to send the request.</param>
|
||||
/// <param name="apiVersion">Optional API version to target the request.</param>
|
||||
/// <returns>
|
||||
/// A task that represents the asynchronous operation. The task result contains a collection of all available <see cref="Article"/> entities.
|
||||
/// </returns>
|
||||
public static Task<IEnumerable<Article>> GetAllArticlesAsync(this IMediator mediator, int? apiVersion = null) => mediator.Send(new GetRequest()
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region PostRequest
|
||||
|
||||
public static Task CreateArticleAsync(this IMediator mediator, Article article, int? apiVersion = null) => mediator.Send(new PostRequest(article)
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
#region PutRequest
|
||||
|
||||
public static Task UpdateArticleAsync(this IMediator mediator, Article article, int? apiVersion = null) => mediator.Send(new PutRequest(article)
|
||||
{
|
||||
ApiVersion = apiVersion
|
||||
});
|
||||
|
||||
#endregion
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Articles/PostRequest.cs
Normal file
17
src/Leanetec.EConnect.Client/Articles/PostRequest.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Leanetec.EConnect.Client.Models;
|
||||
using Leanetec.EConnect.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Articles;
|
||||
|
||||
public record PostRequest(Article Article) : Request, IRequest
|
||||
{
|
||||
}
|
||||
|
||||
public class PostRequestHandler : IRequestHandler<PostRequest>
|
||||
{
|
||||
public Task Handle(PostRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Articles/PutRequest.cs
Normal file
17
src/Leanetec.EConnect.Client/Articles/PutRequest.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using Leanetec.EConnect.Client.Models;
|
||||
using Leanetec.EConnect.Domain.Entities;
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Articles;
|
||||
|
||||
public record PutRequest(Article Article) : Request, IRequest
|
||||
{
|
||||
}
|
||||
|
||||
public class PutRequestHandler : IRequestHandler<PostRequest>
|
||||
{
|
||||
public Task Handle(PostRequest request, CancellationToken cancellationToken)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
49
src/Leanetec.EConnect.Client/Client.cs
Normal file
49
src/Leanetec.EConnect.Client/Client.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Leanetec.EConnect.Client;
|
||||
|
||||
/// <summary>
|
||||
/// Provides a lazily initialized <see cref="IServiceProvider"/> for accessing the EConnect client services,
|
||||
/// including an <see cref="IMediator"/> instance for sending and publishing messages.
|
||||
/// </summary>
|
||||
public static class Client
|
||||
{
|
||||
private static Action<ClientOptions>? _options = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the configuration options for the EConnect client.
|
||||
/// Can only be set once; subsequent attempts to set will result in an exception.
|
||||
/// </summary>
|
||||
public static Action<ClientOptions> Options
|
||||
{
|
||||
get => _options ?? throw new InvalidOperationException("EConnect Client options have not been configured. Please set the 'Client.Options' property before accessing client services.");
|
||||
set
|
||||
{
|
||||
if (_options is null)
|
||||
_options = value;
|
||||
else
|
||||
throw new InvalidOperationException("EConnect Client options have already been configured. Reassignment is not allowed.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lazily initializes the <see cref="IServiceProvider"/> that registers and builds the EConnect client services.
|
||||
/// </summary>
|
||||
private static readonly Lazy<IServiceProvider> _serviceProvider = new(() =>
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddEConnectClient(Options);
|
||||
return services.BuildServiceProvider();
|
||||
});
|
||||
|
||||
/// <summary>
|
||||
/// Gets the initialized <see cref="IServiceProvider"/> that provides access to registered EConnect client services.
|
||||
/// </summary>
|
||||
public static IServiceProvider Provider => _serviceProvider.Value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the <see cref="IMediator"/> instance used for sending commands, queries, and publishing events within the EConnect client.
|
||||
/// </summary>
|
||||
public static IMediator Mediator => Provider.GetRequiredService<IMediator>();
|
||||
}
|
||||
6
src/Leanetec.EConnect.Client/ClientOptions.cs
Normal file
6
src/Leanetec.EConnect.Client/ClientOptions.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Leanetec.EConnect.Client;
|
||||
|
||||
public class ClientOptions
|
||||
{
|
||||
public int ApiVersion { get; set; } = 1;
|
||||
}
|
||||
13
src/Leanetec.EConnect.Client/DependencyInjection.cs
Normal file
13
src/Leanetec.EConnect.Client/DependencyInjection.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Leanetec.EConnect.Client;
|
||||
|
||||
public static class DependencyInjection
|
||||
{
|
||||
public static IServiceCollection AddEConnectClient(this IServiceCollection services, Action<ClientOptions> clientOptions)
|
||||
{
|
||||
services.Configure(clientOptions);
|
||||
services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(DependencyInjection).Assembly));
|
||||
return services;
|
||||
}
|
||||
}
|
||||
17
src/Leanetec.EConnect.Client/Leanetec.EConnect.Client.csproj
Normal file
17
src/Leanetec.EConnect.Client/Leanetec.EConnect.Client.csproj
Normal file
@@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="MediatR" Version="13.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Leanetec.EConnect.Domain\Leanetec.EConnect.Domain.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
16
src/Leanetec.EConnect.Client/Models/Request.cs
Normal file
16
src/Leanetec.EConnect.Client/Models/Request.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using MediatR;
|
||||
|
||||
namespace Leanetec.EConnect.Client.Models;
|
||||
|
||||
public record CommonRequest
|
||||
{
|
||||
public int? ApiVersion { get; set; }
|
||||
}
|
||||
|
||||
public record Request : CommonRequest, IRequest
|
||||
{
|
||||
}
|
||||
|
||||
public record Request<TResponse> : CommonRequest, IRequest<TResponse>
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Article.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Article.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents business partner articles
|
||||
/// </summary>
|
||||
public class Article
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Aval.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Aval.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents aval containers with volume information
|
||||
/// </summary>
|
||||
public class Aval
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/BusinessPartner.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/BusinessPartner.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents business partners
|
||||
/// </summary>
|
||||
public class BusinessPartner
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Documents.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Documents.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents documents of service ordrers
|
||||
/// </summary>
|
||||
public class Documents
|
||||
{
|
||||
}
|
||||
5
src/Leanetec.EConnect.Domain/Entities/Notification.cs
Normal file
5
src/Leanetec.EConnect.Domain/Entities/Notification.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
public class Notification
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
public class NotificationSettings
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Order.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Order.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents orders of tenants
|
||||
/// </summary>
|
||||
public class Order
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/OrderStatus.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/OrderStatus.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents service order states
|
||||
/// </summary>
|
||||
public class OrderStatus
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Tenant.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Tenant.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents tenants that are currently available for the service provider.
|
||||
/// </summary>
|
||||
public class Tenant
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/TenantBerth.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/TenantBerth.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represents berths a specific tenant, with location details.
|
||||
/// </summary>
|
||||
public class TenantBerth
|
||||
{
|
||||
}
|
||||
8
src/Leanetec.EConnect.Domain/Entities/Uom.cs
Normal file
8
src/Leanetec.EConnect.Domain/Entities/Uom.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
/// <summary>
|
||||
/// Represent units of measurement
|
||||
/// </summary>
|
||||
public class Uom
|
||||
{
|
||||
}
|
||||
5
src/Leanetec.EConnect.Domain/Entities/Waste.cs
Normal file
5
src/Leanetec.EConnect.Domain/Entities/Waste.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
namespace Leanetec.EConnect.Domain.Entities;
|
||||
|
||||
public class Waste
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net7.0;net8.0;net9.0</TargetFrameworks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user