Compare commits

..

No commits in common. "571589858a5ac9abc5e8454c687f3e2e6cb23503" and "b6ca6897035b10a7edc842379f45108a180d5f92" have entirely different histories.

4 changed files with 12 additions and 101 deletions

View File

@ -6,7 +6,6 @@ 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);
@ -18,18 +17,7 @@ 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 => builder.Services.AddSwaggerGen(c => c.SwaggerDoc("v1", new OpenApiInfo { Title = "AB-API", Version = "v1", Description = "An Api for the AB-Application" }));
{
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>();

View File

@ -1,18 +1,17 @@
<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>
<GenerateDocumentationFile>true</GenerateDocumentationFile> </PropertyGroup>
</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>

View File

@ -1,13 +1,11 @@
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
{ {
@ -18,11 +16,6 @@ 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)
{ {
@ -31,12 +24,6 @@ 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)
{ {
@ -45,14 +32,7 @@ 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);
@ -60,17 +40,7 @@ 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);
@ -78,19 +48,7 @@ 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);

View File

@ -1,13 +1,11 @@
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
{ {
@ -18,11 +16,6 @@ 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)
{ {
@ -31,16 +24,7 @@ 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);
@ -48,15 +32,7 @@ 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);
@ -64,17 +40,7 @@ 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);