Compare commits
7 Commits
b6ca689703
...
developmen
| Author | SHA1 | Date | |
|---|---|---|---|
| 585d8883b5 | |||
|
|
e9190e6cfa | ||
|
|
87fb83efd3 | ||
|
|
c002e7ac1e | ||
| cf344e6eaf | |||
| 571589858a | |||
| 0e1c464cc1 |
31
AB-API.sln
31
AB-API.sln
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
|||||||
# Visual Studio Version 17
|
# Visual Studio Version 17
|
||||||
VisualStudioVersion = 17.4.33205.214
|
VisualStudioVersion = 17.4.33205.214
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.WEB", "AB-API\AB.WEB.csproj", "{45855EEB-EA31-476F-A020-1A3B71AD725A}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.WEB", "AB.WEB\AB.WEB.csproj", "{45855EEB-EA31-476F-A020-1A3B71AD725A}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Domain", "AB.Domain\AB.Domain.csproj", "{9F60492C-A480-4056-983D-0F6B1A1ABD1B}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Domain", "AB.Domain\AB.Domain.csproj", "{9F60492C-A480-4056-983D-0F6B1A1ABD1B}"
|
||||||
EndProject
|
EndProject
|
||||||
@@ -11,13 +11,25 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Services", "AB.Services\
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Contracts", "AB.Contracts\AB.Contracts.csproj", "{9319695E-2237-49E2-80CD-761F53364421}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Contracts", "AB.Contracts\AB.Contracts.csproj", "{9319695E-2237-49E2-80CD-761F53364421}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.Services.Abstractions", "AB.Services.Abstractions\AB.Services.Abstractions.csproj", "{4E3D1E97-AD83-4F66-825E-105441AF4E15}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Services.Abstractions", "AB.Services.Abstractions\AB.Services.Abstractions.csproj", "{4E3D1E97-AD83-4F66-825E-105441AF4E15}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{AD8DD52C-57EC-455A-9A8D-E50009FCE608}"
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{AD8DD52C-57EC-455A-9A8D-E50009FCE608}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.Persistence", "AB.Persistence\AB.Persistence.csproj", "{BF2F36D4-6EF4-43AB-840F-0336EB1723EC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Persistence", "AB.Persistence\AB.Persistence.csproj", "{BF2F36D4-6EF4-43AB-840F-0336EB1723EC}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.API", "AB.API\AB.API.csproj", "{7595A349-8990-467D-8122-8E79931359DC}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.API", "AB.API\AB.API.csproj", "{7595A349-8990-467D-8122-8E79931359DC}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{82B06293-18B6-44FF-9D74-18DE555BE86A}"
|
||||||
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.Tests", "AB.Tests\AB.Tests.csproj", "{8FF5BC04-5978-4240-BD91-A65524C35681}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0DF9D27D-42B1-4DD8-9815-60E9D204055F}"
|
||||||
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solutionFiles", "solutionFiles", "{E62D3C80-1256-4095-ACC3-82F7E6D67D1C}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.gitignore = .gitignore
|
||||||
|
README.md = README.md
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -53,13 +65,24 @@ Global
|
|||||||
{7595A349-8990-467D-8122-8E79931359DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{7595A349-8990-467D-8122-8E79931359DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{7595A349-8990-467D-8122-8E79931359DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{7595A349-8990-467D-8122-8E79931359DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{7595A349-8990-467D-8122-8E79931359DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
{7595A349-8990-467D-8122-8E79931359DC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{8FF5BC04-5978-4240-BD91-A65524C35681}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{8FF5BC04-5978-4240-BD91-A65524C35681}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{8FF5BC04-5978-4240-BD91-A65524C35681}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{8FF5BC04-5978-4240-BD91-A65524C35681}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(NestedProjects) = preSolution
|
GlobalSection(NestedProjects) = preSolution
|
||||||
|
{45855EEB-EA31-476F-A020-1A3B71AD725A} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
|
{9F60492C-A480-4056-983D-0F6B1A1ABD1B} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
|
{74E74C3E-8A8E-4771-894B-A2919B3422E5} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
|
{9319695E-2237-49E2-80CD-761F53364421} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
|
{4E3D1E97-AD83-4F66-825E-105441AF4E15} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
|
{AD8DD52C-57EC-455A-9A8D-E50009FCE608} = {0DF9D27D-42B1-4DD8-9815-60E9D204055F}
|
||||||
{BF2F36D4-6EF4-43AB-840F-0336EB1723EC} = {AD8DD52C-57EC-455A-9A8D-E50009FCE608}
|
{BF2F36D4-6EF4-43AB-840F-0336EB1723EC} = {AD8DD52C-57EC-455A-9A8D-E50009FCE608}
|
||||||
{7595A349-8990-467D-8122-8E79931359DC} = {AD8DD52C-57EC-455A-9A8D-E50009FCE608}
|
{7595A349-8990-467D-8122-8E79931359DC} = {AD8DD52C-57EC-455A-9A8D-E50009FCE608}
|
||||||
|
{8FF5BC04-5978-4240-BD91-A65524C35681} = {82B06293-18B6-44FF-9D74-18DE555BE86A}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {C7D1722E-5C50-4F16-BA7D-79977DD1D621}
|
SolutionGuid = {C7D1722E-5C50-4F16-BA7D-79977DD1D621}
|
||||||
|
|||||||
@@ -1,17 +1,18 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\AB.Services.Abstractions\AB.Services.Abstractions.csproj" />
|
<ProjectReference Include="..\AB.Services.Abstractions\AB.Services.Abstractions.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using AB.Contracts;
|
using AB.Contracts;
|
||||||
using AB.Services.Abstractions;
|
using AB.Services.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AB.API.Controllers.BusinessPartner;
|
namespace AB.API.Controllers.BusinessPartner;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/customers")]
|
[Route("api/customers")]
|
||||||
|
[Produces("application/json")]
|
||||||
public class CustomerController : ControllerBase
|
public class CustomerController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -16,6 +18,11 @@ public class CustomerController : ControllerBase
|
|||||||
_customerService = customerService;
|
_customerService = customerService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abrufen aller Kunden
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns>Eine Liste aller Kunden</returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<CustomerDto>>> GetCustomers(CancellationToken cancellationToken)
|
public async Task<ActionResult<IEnumerable<CustomerDto>>> GetCustomers(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -24,6 +31,12 @@ public class CustomerController : ControllerBase
|
|||||||
return Ok(customers);
|
return Ok(customers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abrufen eines Kunden anhand seiner Id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns>Den Kunden mit der angegeben Id</returns>
|
||||||
[HttpGet("{customerId:guid}")]
|
[HttpGet("{customerId:guid}")]
|
||||||
public async Task<ActionResult<CustomerDto>> GetCustomerById(Guid customerId, CancellationToken cancellationToken)
|
public async Task<ActionResult<CustomerDto>> GetCustomerById(Guid customerId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -32,7 +45,14 @@ public class CustomerController : ControllerBase
|
|||||||
return Ok(customer);
|
return Ok(customer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anlegen eines neuen Kunden
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerForCreation"></param>
|
||||||
|
/// <returns>Einen neu erstellten Kunden</returns>
|
||||||
|
/// <response code="201">Kunde wurde erstellt</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||||
public async Task<CreatedAtActionResult> CreateCustomer([FromBody] CustomerForCreationDto customerForCreation)
|
public async Task<CreatedAtActionResult> CreateCustomer([FromBody] CustomerForCreationDto customerForCreation)
|
||||||
{
|
{
|
||||||
var customerDto = await _customerService.CreateAsync(customerForCreation);
|
var customerDto = await _customerService.CreateAsync(customerForCreation);
|
||||||
@@ -40,7 +60,17 @@ public class CustomerController : ControllerBase
|
|||||||
return CreatedAtAction(nameof(CreateCustomer), new { customerId = customerDto.Id }, customerDto);
|
return CreatedAtAction(nameof(CreateCustomer), new { customerId = customerDto.Id }, customerDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Löschen eines vorhandenen Kunden
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="204">Kunde wurde gelöscht</response>
|
||||||
|
/// <response code="404">Kunde wurde nicht gefunden</response>
|
||||||
[HttpDelete("{customerId:guid}")]
|
[HttpDelete("{customerId:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<NoContentResult> DeleteCustomer(Guid customerId, CancellationToken cancellationToken)
|
public async Task<NoContentResult> DeleteCustomer(Guid customerId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _customerService.DeleteAsync(customerId, cancellationToken);
|
await _customerService.DeleteAsync(customerId, cancellationToken);
|
||||||
@@ -48,7 +78,19 @@ public class CustomerController : ControllerBase
|
|||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Bearbeiten eines vorhanden Kunden
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="customerId"></param>
|
||||||
|
/// <param name="customerForUpdate"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns>Den veränderten Kunden
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">Kunde wurde bearbeitet</response>
|
||||||
|
/// <response code="404">Kunde wurde nicht gefunden</response>
|
||||||
[HttpPut("{customerId:guid}")]
|
[HttpPut("{customerId:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult<CustomerDto>> UpdateCustomer(Guid customerId, CustomerForUpdateDto customerForUpdate, CancellationToken cancellationToken)
|
public async Task<ActionResult<CustomerDto>> UpdateCustomer(Guid customerId, CustomerForUpdateDto customerForUpdate, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var customerDto = await _customerService.UpdateAsync(customerId, customerForUpdate, cancellationToken);
|
var customerDto = await _customerService.UpdateAsync(customerId, customerForUpdate, cancellationToken);
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
using AB.Contracts;
|
using AB.Contracts;
|
||||||
using AB.Services.Abstractions;
|
using AB.Services.Abstractions;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
namespace AB.API.Controllers.BusinessPartner;
|
namespace AB.API.Controllers.BusinessPartner;
|
||||||
|
|
||||||
[ApiController]
|
[ApiController]
|
||||||
[Route("api/suppliers")]
|
[Route("api/suppliers")]
|
||||||
|
[Produces("application/json")]
|
||||||
public class SupplierController : ControllerBase
|
public class SupplierController : ControllerBase
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -16,6 +18,11 @@ public class SupplierController : ControllerBase
|
|||||||
_supplierService = supplierService;
|
_supplierService = supplierService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abrufen aller Lieferanten
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<IEnumerable<SupplierDto>>> GetSupplieres(CancellationToken cancellationToken)
|
public async Task<ActionResult<IEnumerable<SupplierDto>>> GetSupplieres(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
@@ -24,7 +31,16 @@ public class SupplierController : ControllerBase
|
|||||||
return Ok(suppliers);
|
return Ok(suppliers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Abrufen eines Lieferanten anhand seiner Id
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="supplierId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="404">Lieferant wurde nicht gefunden</response>
|
||||||
[HttpGet("{supplierId:guid}")]
|
[HttpGet("{supplierId:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<ActionResult<SupplierDto>> GetSupplierById(Guid supplierId, CancellationToken cancellationToken)
|
public async Task<ActionResult<SupplierDto>> GetSupplierById(Guid supplierId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var supplierDto = await _supplierService.GetSupplierByIdAsync(supplierId, cancellationToken);
|
var supplierDto = await _supplierService.GetSupplierByIdAsync(supplierId, cancellationToken);
|
||||||
@@ -32,7 +48,15 @@ public class SupplierController : ControllerBase
|
|||||||
return Ok(supplierDto);
|
return Ok(supplierDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Anlegen eines neuen Lieferanten
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="supplierForCreation"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns>Einen neu erstellen Kunden</returns>
|
||||||
|
/// <response code="201">Lieferant wurde erstellt</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
|
[ProducesResponseType(StatusCodes.Status201Created)]
|
||||||
public async Task<CreatedAtActionResult> CreateSupplier([FromBody] SupplierForCreationDto supplierForCreation, CancellationToken cancellationToken)
|
public async Task<CreatedAtActionResult> CreateSupplier([FromBody] SupplierForCreationDto supplierForCreation, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var supplierDto = await _supplierService.CreateAsync(supplierForCreation, cancellationToken);
|
var supplierDto = await _supplierService.CreateAsync(supplierForCreation, cancellationToken);
|
||||||
@@ -40,7 +64,17 @@ public class SupplierController : ControllerBase
|
|||||||
return CreatedAtAction(nameof(CreateSupplier), new { id = supplierDto.Id }, supplierDto);
|
return CreatedAtAction(nameof(CreateSupplier), new { id = supplierDto.Id }, supplierDto);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Löschen eines vorhanden Lieferanten
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="supplierId"></param>
|
||||||
|
/// <param name="cancellationToken"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="204">Lieferant wurde gelöscht</response>
|
||||||
|
/// <response code="404">Lieferant wurde nicht gefunden</response>
|
||||||
[HttpDelete("{supplierId:guid}")]
|
[HttpDelete("{supplierId:guid}")]
|
||||||
|
[ProducesResponseType(StatusCodes.Status204NoContent)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status404NotFound)]
|
||||||
public async Task<NoContentResult> DeleteSupplier(Guid supplierId, CancellationToken cancellationToken)
|
public async Task<NoContentResult> DeleteSupplier(Guid supplierId, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
await _supplierService.DeleteAsync(supplierId, cancellationToken);
|
await _supplierService.DeleteAsync(supplierId, cancellationToken);
|
||||||
|
|||||||
31
AB.Tests/AB.Tests.csproj
Normal file
31
AB.Tests/AB.Tests.csproj
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
<IsTestProject>true</IsTestProject>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="FluentAssertions" Version="6.11.0" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
|
||||||
|
<PackageReference Include="Moq" Version="4.18.4" />
|
||||||
|
<PackageReference Include="xunit" Version="2.4.2" />
|
||||||
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.2.0">
|
||||||
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\AB.Services\AB.Services.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
105
AB.Tests/CustomerTests.cs
Normal file
105
AB.Tests/CustomerTests.cs
Normal file
@@ -0,0 +1,105 @@
|
|||||||
|
using AB.Contracts;
|
||||||
|
using AB.Domain.Entities;
|
||||||
|
using AB.Domain.Exceptions;
|
||||||
|
using AB.Domain.Repositories;
|
||||||
|
using AB.Services;
|
||||||
|
|
||||||
|
namespace AB.Tests
|
||||||
|
{
|
||||||
|
public class CustomerTests
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly Mock<IUnitOfWork> _unitOfWorkMock = new Mock<IUnitOfWork>();
|
||||||
|
|
||||||
|
private readonly Mock<ICustomerRepository> _customerRepositoryMock = new Mock<ICustomerRepository>();
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async void TestCreateCustomer_Sucess()
|
||||||
|
{
|
||||||
|
var customerService = new CustomerService(_customerRepositoryMock.Object, _unitOfWorkMock.Object);
|
||||||
|
|
||||||
|
var customerForCreationDto = new CustomerForCreationDto
|
||||||
|
{
|
||||||
|
Salutaion = "Firma",
|
||||||
|
Name1 = "Arik Meyer",
|
||||||
|
Email = "test@test.de",
|
||||||
|
PhoneNumber = "1234567890",
|
||||||
|
Iban = "DE12345890",
|
||||||
|
};
|
||||||
|
|
||||||
|
var customerDto = await customerService.CreateAsync(customerForCreationDto);
|
||||||
|
|
||||||
|
customerDto.Salutaion.Should().Be(customerForCreationDto.Salutaion);
|
||||||
|
customerDto.Name1.Should().Be(customerForCreationDto.Name1);
|
||||||
|
customerDto.Email.Should().Be(customerForCreationDto.Email);
|
||||||
|
customerDto.PhoneNumber.Should().Be(customerForCreationDto.PhoneNumber);
|
||||||
|
customerDto.Iban.Should().Be(customerForCreationDto.Iban);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
private async void TestGetCustomers_Sucess()
|
||||||
|
{
|
||||||
|
CancellationToken cancellationToken = default;
|
||||||
|
|
||||||
|
var customerList = new List<Customer>
|
||||||
|
{
|
||||||
|
new Customer
|
||||||
|
{
|
||||||
|
CustomerId = Guid.NewGuid(),
|
||||||
|
Salutation = "Herr",
|
||||||
|
},
|
||||||
|
new Customer
|
||||||
|
{
|
||||||
|
CustomerId = Guid.NewGuid(),
|
||||||
|
Name1 = "Peter Sprudel"
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
_customerRepositoryMock.Setup(repo => repo.GetAllAsync(cancellationToken)).ReturnsAsync(customerList);
|
||||||
|
|
||||||
|
var customerService = new CustomerService(_customerRepositoryMock.Object, _unitOfWorkMock.Object);
|
||||||
|
|
||||||
|
var dtoList = await customerService.GetAllAsync(cancellationToken);
|
||||||
|
|
||||||
|
dtoList.Should().NotBeNullOrEmpty();
|
||||||
|
|
||||||
|
dtoList.ElementAt(0).Salutaion.Should().Be(customerList[0].Salutation);
|
||||||
|
dtoList.ElementAt(0).Id.Should().Be(customerList[0].CustomerId);
|
||||||
|
|
||||||
|
dtoList.ElementAt(1).Name1.Should().Be(customerList[1].Name1);
|
||||||
|
dtoList.ElementAt(1).Id.Should().Be(customerList[1].CustomerId);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
private async void TestGetCustomerById_Exception()
|
||||||
|
{
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
CancellationToken cancellationToken = default;
|
||||||
|
_customerRepositoryMock.Setup(repo => repo.GetByIdAsync(id, cancellationToken)).ThrowsAsync(new BusinessPartnerNotFoundException(id));
|
||||||
|
|
||||||
|
var customerService = new CustomerService(_customerRepositoryMock.Object, _unitOfWorkMock.Object);
|
||||||
|
|
||||||
|
var exec = () => customerService.GetByIdAsync(id, cancellationToken);
|
||||||
|
|
||||||
|
await exec.Should().ThrowExactlyAsync<BusinessPartnerNotFoundException>();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
private async void TestGetCustomerById_Sucess()
|
||||||
|
{
|
||||||
|
var id = Guid.NewGuid();
|
||||||
|
CancellationToken cancellationToken = default;
|
||||||
|
var customer = new Customer { CustomerId = id };
|
||||||
|
_customerRepositoryMock.Setup(repo => repo.GetByIdAsync(id, cancellationToken)).ReturnsAsync(customer);
|
||||||
|
|
||||||
|
var customerService = new CustomerService(_customerRepositoryMock.Object, _unitOfWorkMock.Object);
|
||||||
|
|
||||||
|
var dto = await customerService.GetByIdAsync(id, cancellationToken);
|
||||||
|
|
||||||
|
dto.Should().NotBeNull();
|
||||||
|
dto.Id.Should().Be(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
3
AB.Tests/Usings.cs
Normal file
3
AB.Tests/Usings.cs
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
global using Xunit;
|
||||||
|
global using FluentAssertions;
|
||||||
|
global using Moq;
|
||||||
@@ -6,6 +6,7 @@ using AB.Services.Abstractions;
|
|||||||
using AB_API.Middleware;
|
using AB_API.Middleware;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
@@ -17,7 +18,18 @@ builder.Services.AddControllers().AddApplicationPart(typeof(AB.API.AssemblyRefer
|
|||||||
|
|
||||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||||
builder.Services.AddEndpointsApiExplorer();
|
builder.Services.AddEndpointsApiExplorer();
|
||||||
builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "AB-API", Version = "v1", Description = "An Api for the AB-Application" }));
|
builder.Services.AddSwaggerGen(c =>
|
||||||
|
{
|
||||||
|
c.SwaggerDoc("v1", new OpenApiInfo
|
||||||
|
{
|
||||||
|
Title = "AB-API",
|
||||||
|
Version = "v1",
|
||||||
|
Description = "An Api for the AB-Application"
|
||||||
|
});
|
||||||
|
|
||||||
|
var xmlFilename = $"{typeof(AB.API.AssemblyReference).Assembly.GetName().Name}.xml";
|
||||||
|
c.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
|
||||||
|
});
|
||||||
|
|
||||||
builder.Services.AddScoped<ICustomerService, CustomerService>();
|
builder.Services.AddScoped<ICustomerService, CustomerService>();
|
||||||
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
|
builder.Services.AddScoped<ICustomerRepository, CustomerRepository>();
|
||||||
13
README.md
13
README.md
@@ -6,3 +6,16 @@ Hier ein Link zur der Collection unserer Rest-API:
|
|||||||
https://elements.getpostman.com/redirect?entityId=19696438-2f494a5b-ad52-4fb3-a864-ba739b638ca7&entityType=collection
|
https://elements.getpostman.com/redirect?entityId=19696438-2f494a5b-ad52-4fb3-a864-ba739b638ca7&entityType=collection
|
||||||
|
|
||||||
Visualisierung der Rest-API erfolgt via Swagger: Swagger ist unter dem Endpunkt /swagger/index.html zu erreichen.
|
Visualisierung der Rest-API erfolgt via Swagger: Swagger ist unter dem Endpunkt /swagger/index.html zu erreichen.
|
||||||
|
|
||||||
|
Geplante Endpunkte:
|
||||||
|
|
||||||
|
PUT suppliers/{id}
|
||||||
|
|
||||||
|
POST products/
|
||||||
|
GET products/
|
||||||
|
GET products/{id}
|
||||||
|
PUT products/{id}
|
||||||
|
DELETE products/{id}
|
||||||
|
|
||||||
|
POST invoices/
|
||||||
|
GET invoices/{id}
|
||||||
Reference in New Issue
Block a user