create project and customercontroller
This commit is contained in:
parent
5aa09670bc
commit
d5aeb0a06e
20
AB-API.sln
20
AB-API.sln
@ -3,7 +3,13 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.4.33205.214
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB-API", "AB-API\AB-API.csproj", "{45855EEB-EA31-476F-A020-1A3B71AD725A}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AB.WEB", "AB-API\AB.WEB.csproj", "{45855EEB-EA31-476F-A020-1A3B71AD725A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.Domain", "AB.Domain\AB.Domain.csproj", "{9F60492C-A480-4056-983D-0F6B1A1ABD1B}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.Services", "AB.Services\AB.Services.csproj", "{74E74C3E-8A8E-4771-894B-A2919B3422E5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AB.Contracts", "AB.Contracts\AB.Contracts.csproj", "{9319695E-2237-49E2-80CD-761F53364421}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -15,6 +21,18 @@ Global
|
||||
{45855EEB-EA31-476F-A020-1A3B71AD725A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{45855EEB-EA31-476F-A020-1A3B71AD725A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{45855EEB-EA31-476F-A020-1A3B71AD725A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9F60492C-A480-4056-983D-0F6B1A1ABD1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9F60492C-A480-4056-983D-0F6B1A1ABD1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9F60492C-A480-4056-983D-0F6B1A1ABD1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9F60492C-A480-4056-983D-0F6B1A1ABD1B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{74E74C3E-8A8E-4771-894B-A2919B3422E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{74E74C3E-8A8E-4771-894B-A2919B3422E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{74E74C3E-8A8E-4771-894B-A2919B3422E5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{74E74C3E-8A8E-4771-894B-A2919B3422E5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9319695E-2237-49E2-80CD-761F53364421}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{9319695E-2237-49E2-80CD-761F53364421}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{9319695E-2237-49E2-80CD-761F53364421}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{9319695E-2237-49E2-80CD-761F53364421}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -2,7 +2,7 @@ var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
// Add services to the container.
|
||||
|
||||
builder.Services.AddControllers();
|
||||
builder.Services.AddControllers().AddApplicationPart(typeof(AB.API.AssemblyReference).Assembly);
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
|
9
AB.API/AB.API.csproj
Normal file
9
AB.API/AB.API.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
12
AB.API/AssemblyReference.cs
Normal file
12
AB.API/AssemblyReference.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.API
|
||||
{
|
||||
public class AssemblyReference
|
||||
{
|
||||
}
|
||||
}
|
53
AB.API/Controllers/CustomerController.cs
Normal file
53
AB.API/Controllers/CustomerController.cs
Normal file
@ -0,0 +1,53 @@
|
||||
using AB.Contracts;
|
||||
using AB.Services.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.API.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/customers")]
|
||||
public class CustomerController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly ICustomerService _customerService;
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetCustomers(CancellationToken cancellationToken)
|
||||
{
|
||||
var customers = await _customerService.GetAllAsync(cancellationToken);
|
||||
|
||||
return Ok(customers);
|
||||
}
|
||||
|
||||
[HttpGet("{customerId:guid}")]
|
||||
public async Task<IActionResult> GetCustomerById(Guid customerId, CancellationToken cancellationToken)
|
||||
{
|
||||
var customer = await _customerService.GetByIdAsync(customerId, cancellationToken);
|
||||
|
||||
return Ok(customer);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateCustomer([FromBody] CustomerForCreationDto customerForCreation)
|
||||
{
|
||||
var customerDto = await _customerService.CreateAsync(customerForCreation);
|
||||
|
||||
return CreatedAtAction(nameof(CreateCustomer), new {customerId = customerDto.Id}, customerDto);
|
||||
}
|
||||
|
||||
[HttpDelete("{customerId:guid}")]
|
||||
public async Task<IActionResult> DeleteCustomer(Guid customerId, CancellationToken cancellationToken)
|
||||
{
|
||||
await _customerService.DeleteAsync(customerId, cancellationToken);
|
||||
|
||||
return NoContent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
9
AB.Contracts/AB.Contracts.csproj
Normal file
9
AB.Contracts/AB.Contracts.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
15
AB.Contracts/CustomerDto.cs
Normal file
15
AB.Contracts/CustomerDto.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Contracts
|
||||
{
|
||||
public class CustomerDto
|
||||
{
|
||||
|
||||
public Guid Id { get; set; }
|
||||
|
||||
}
|
||||
}
|
12
AB.Contracts/CustomerForCreationDto.cs
Normal file
12
AB.Contracts/CustomerForCreationDto.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Contracts
|
||||
{
|
||||
public class CustomerForCreationDto
|
||||
{
|
||||
}
|
||||
}
|
12
AB.Contracts/SupplierForCreationDto.cs
Normal file
12
AB.Contracts/SupplierForCreationDto.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Contracts
|
||||
{
|
||||
public class SupplierForCreationDto
|
||||
{
|
||||
}
|
||||
}
|
9
AB.Domain/AB.Domain.csproj
Normal file
9
AB.Domain/AB.Domain.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
14
AB.Domain/Entities/Customer.cs
Normal file
14
AB.Domain/Entities/Customer.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Entities
|
||||
{
|
||||
public class Customer
|
||||
{
|
||||
Guid coutomerId;
|
||||
|
||||
}
|
||||
}
|
14
AB.Domain/Entities/Product.cs
Normal file
14
AB.Domain/Entities/Product.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Entities
|
||||
{
|
||||
public class Product
|
||||
{
|
||||
Guid productId;
|
||||
|
||||
}
|
||||
}
|
14
AB.Domain/Entities/Supplier.cs
Normal file
14
AB.Domain/Entities/Supplier.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Entities
|
||||
{
|
||||
public class Supplier
|
||||
{
|
||||
|
||||
Guid supplierId;
|
||||
}
|
||||
}
|
17
AB.Domain/Exceptions/BusinessPartnerNotFoundException.cs
Normal file
17
AB.Domain/Exceptions/BusinessPartnerNotFoundException.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Exceptions
|
||||
{
|
||||
public class BusinessPartnerNotFoundException : NotFoundException
|
||||
{
|
||||
|
||||
public BusinessPartnerNotFoundException(Guid businessPartnerId)
|
||||
: base ($"The BusinessPartner with the indetifier {businessPartnerId} was not found.")
|
||||
{ }
|
||||
|
||||
}
|
||||
}
|
20
AB.Domain/Exceptions/NotFoundException.cs
Normal file
20
AB.Domain/Exceptions/NotFoundException.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Exceptions
|
||||
{
|
||||
|
||||
[Serializable]
|
||||
public abstract class NotFoundException : Exception
|
||||
{
|
||||
public NotFoundException() { }
|
||||
public NotFoundException(string message) : base(message) { }
|
||||
public NotFoundException(string message, Exception inner) : base(message, inner) { }
|
||||
protected NotFoundException(
|
||||
System.Runtime.Serialization.SerializationInfo info,
|
||||
System.Runtime.Serialization.StreamingContext context) : base(info, context) { }
|
||||
}
|
||||
}
|
12
AB.Domain/Repositories/ICustomerRepository.cs
Normal file
12
AB.Domain/Repositories/ICustomerRepository.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Repositories
|
||||
{
|
||||
public class ICustomerRepository
|
||||
{
|
||||
}
|
||||
}
|
12
AB.Domain/Repositories/ISupplierRepository.cs
Normal file
12
AB.Domain/Repositories/ISupplierRepository.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Repositories
|
||||
{
|
||||
public class ISupplierRepository
|
||||
{
|
||||
}
|
||||
}
|
12
AB.Domain/Repositories/IUnitOfWork.cs
Normal file
12
AB.Domain/Repositories/IUnitOfWork.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Domain.Repositories
|
||||
{
|
||||
public class IUnitOfWork
|
||||
{
|
||||
}
|
||||
}
|
9
AB.Persistence/AB.Persistence.csproj
Normal file
9
AB.Persistence/AB.Persistence.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
9
AB.Services.Abstractions/AB.Services.Abstractions.csproj
Normal file
9
AB.Services.Abstractions/AB.Services.Abstractions.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
17
AB.Services.Abstractions/ICustomerService.cs
Normal file
17
AB.Services.Abstractions/ICustomerService.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using AB.Contracts;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Services.Abstractions
|
||||
{
|
||||
public interface ICustomerService
|
||||
{
|
||||
Task<CustomerDto> CreateAsync(CustomerForCreationDto customerForCreation);
|
||||
Task DeleteAsync(Guid customerId, CancellationToken cancellationToken);
|
||||
Task<IEnumerable<CustomerDto>> GetAllAsync(CancellationToken cancellationToken);
|
||||
Task<CustomerDto> GetByIdAsync(Guid customerId, CancellationToken cancellationToken);
|
||||
}
|
||||
}
|
9
AB.Services/AB.Services.csproj
Normal file
9
AB.Services/AB.Services.csproj
Normal file
@ -0,0 +1,9 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
15
AB.Services/CustomerService.cs
Normal file
15
AB.Services/CustomerService.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using AB.Contracts;
|
||||
using AB.Services.Abstractions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AB.Services
|
||||
{
|
||||
internal class CustomerService : ICustomerService
|
||||
{
|
||||
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user