-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SOA-007][Feature] Build the Business module (Services) (#33)
- Loading branch information
1 parent
43f0a51
commit f878d47
Showing
22 changed files
with
379 additions
and
3 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,6 @@ | ||
namespace Contracts.Business.Abstracts | ||
{ | ||
public interface IAbstractService | ||
{ | ||
} | ||
} |
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,13 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Shared\Shared.csproj" /> | ||
</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,7 @@ | ||
namespace Contracts.Business.Entities | ||
{ | ||
public interface ICompanyService | ||
{ | ||
CompanyDto? GetById(bool isTrackChanges, Guid id); | ||
} | ||
} |
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,15 @@ | ||
namespace Contracts.Business.Entities | ||
{ | ||
public interface ICustomerService | ||
{ | ||
CustomerDto? GetById(bool isTrackChanges, Guid id); | ||
|
||
IEnumerable<CustomerDto> GetAll(bool isTrackChanges); | ||
|
||
void Create(CustomerForCreationDto creationDto); | ||
|
||
void SoftDelete(Guid id); | ||
|
||
void HardDelete(Guid id); | ||
} | ||
} |
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,15 @@ | ||
namespace Contracts.Business.Entities | ||
{ | ||
public interface IEmployeeService | ||
{ | ||
EmployeeDto? GetById(bool isTrackChanges, Guid id); | ||
|
||
IEnumerable<EmployeeDto> GetAll(bool isTrackChanges); | ||
|
||
void Create(EmployeeForCreationDto creationDto); | ||
|
||
void SoftDelete(Guid id); | ||
|
||
void HardDelete(Guid id); | ||
} | ||
} |
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,15 @@ | ||
namespace Contracts.Business.Entities | ||
{ | ||
public interface IProductService | ||
{ | ||
ProductDto? GetById(bool isTrackChanges, Guid id); | ||
|
||
IEnumerable<ProductDto> GetAll(bool isTrackChanges); | ||
|
||
void Create(ProductForCreationDto creationDto); | ||
|
||
void SoftDelete(Guid id); | ||
|
||
void HardDelete(Guid id); | ||
} | ||
} |
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,15 @@ | ||
namespace Contracts.Business.Entities | ||
{ | ||
public interface IStoreService | ||
{ | ||
StoreDto? GetById(bool isTrackChanges, Guid id); | ||
|
||
IEnumerable<StoreDto> GetAll(bool isTrackChanges); | ||
|
||
void Create(StoreForCreationDto creationDto); | ||
|
||
void SoftDelete(Guid id); | ||
|
||
void HardDelete(Guid id); | ||
} | ||
} |
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,17 @@ | ||
using Contracts.Business.Entities; | ||
|
||
namespace Contracts.Business.Managers | ||
{ | ||
public interface IServiceManager | ||
{ | ||
ICompanyService Company { get; } | ||
|
||
ICustomerService Customer { get; } | ||
|
||
IEmployeeService Employee { get; } | ||
|
||
IProductService Product { get; } | ||
|
||
IStoreService Store { get; } | ||
} | ||
} |
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,2 @@ | ||
global using Shared.DTOs.Inputs.FromBody.CreationDtos; | ||
global using Shared.DTOs.Outputs.EntityDtos; |
19 changes: 19 additions & 0 deletions
19
Implementations/eShopOnlineBusiness/Abstracts/AbstractService.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 Contracts.Business.Abstracts; | ||
using Contracts.Repositories.Managers; | ||
using Contracts.Utilities.Mapper; | ||
|
||
namespace eShopOnlineBusiness.Abstracts | ||
{ | ||
public abstract class AbstractService : IAbstractService | ||
{ | ||
protected readonly IRepositoryManager _repositoryManager; | ||
protected readonly IMapperService _mapperService; | ||
|
||
protected AbstractService(ServiceParams serviceParams) | ||
{ | ||
_repositoryManager = serviceParams.RepositoryManager; | ||
_mapperService = serviceParams.MapperService; | ||
} | ||
|
||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Implementations/eShopOnlineBusiness/Entities/CompanyService.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 @@ | ||
namespace eShopOnlineBusiness.Entities | ||
{ | ||
internal sealed class CompanyService : AbstractService, ICompanyService | ||
{ | ||
public CompanyService(ServiceParams serviceParams) : base(serviceParams) | ||
{ | ||
} | ||
|
||
public CompanyDto? GetById(bool isTrackChanges, Guid id) | ||
{ | ||
Company? company = _repositoryManager.Company.GetById(isTrackChanges, id); | ||
if (company == null) | ||
{ | ||
return null; | ||
} | ||
return _mapperService.Execute<Company, CompanyDto>(company); | ||
} | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Implementations/eShopOnlineBusiness/Entities/CustomerService.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,41 @@ | ||
namespace eShopOnlineBusiness.Entities | ||
{ | ||
internal sealed class CustomerService : AbstractService, ICustomerService | ||
{ | ||
public CustomerService(ServiceParams serviceParams) : base(serviceParams) | ||
{ | ||
} | ||
|
||
public IEnumerable<CustomerDto> GetAll(bool isTrackChanges) | ||
{ | ||
IEnumerable<Customer> customers = _repositoryManager.Customer.GetAll(isTrackChanges); | ||
return _mapperService.Execute<IEnumerable<Customer>, IEnumerable<CustomerDto>>(customers); | ||
} | ||
|
||
public CustomerDto? GetById(bool isTrackChanges, Guid id) | ||
{ | ||
Customer? customer = _repositoryManager.Customer.GetById(isTrackChanges, id); | ||
if (customer == null) | ||
{ | ||
return null; | ||
} | ||
return _mapperService.Execute<Customer, CustomerDto>(customer); | ||
} | ||
|
||
public void Create(CustomerForCreationDto creationDto) | ||
{ | ||
Customer newCustomer = _mapperService.Execute<CustomerForCreationDto, Customer>(creationDto); | ||
_repositoryManager.Customer.Create(newCustomer); | ||
} | ||
|
||
public void SoftDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void HardDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Implementations/eShopOnlineBusiness/Entities/EmployeeService.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,34 @@ | ||
namespace eShopOnlineBusiness.Entities | ||
{ | ||
internal sealed class EmployeeService : AbstractService, IEmployeeService | ||
{ | ||
public EmployeeService(ServiceParams serviceParams) : base(serviceParams) | ||
{ | ||
} | ||
|
||
public IEnumerable<EmployeeDto> GetAll(bool isTrackChanges) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public EmployeeDto? GetById(bool isTrackChanges, Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Create(EmployeeForCreationDto creationDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SoftDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void HardDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Implementations/eShopOnlineBusiness/Entities/ProductService.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,34 @@ | ||
namespace eShopOnlineBusiness.Entities | ||
{ | ||
internal sealed class ProductService : AbstractService, IProductService | ||
{ | ||
public ProductService(ServiceParams serviceParams) : base(serviceParams) | ||
{ | ||
} | ||
|
||
public IEnumerable<ProductDto> GetAll(bool isTrackChanges) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public ProductDto? GetById(bool isTrackChanges, Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Create(ProductForCreationDto creationDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SoftDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void HardDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
Implementations/eShopOnlineBusiness/Entities/StoreService.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,34 @@ | ||
namespace eShopOnlineBusiness.Entities | ||
{ | ||
internal sealed class StoreService : AbstractService, IStoreService | ||
{ | ||
public StoreService(ServiceParams serviceParams) : base(serviceParams) | ||
{ | ||
} | ||
|
||
public IEnumerable<StoreDto> GetAll(bool isTrackChanges) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public StoreDto? GetById(bool isTrackChanges, Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void Create(StoreForCreationDto creationDto) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void SoftDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
|
||
public void HardDelete(Guid id) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
Implementations/eShopOnlineBusiness/Managers/ServiceManager.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,33 @@ | ||
using Contracts.Business.Managers; | ||
using eShopOnlineBusiness.Entities; | ||
|
||
namespace eShopOnlineBusiness.Managers | ||
{ | ||
public sealed class ServiceManager : IServiceManager | ||
{ | ||
private readonly Lazy<ICompanyService> _company; | ||
private readonly Lazy<ICustomerService> _customer; | ||
private readonly Lazy<IEmployeeService> _employee; | ||
private readonly Lazy<IProductService> _product; | ||
private readonly Lazy<IStoreService> _store; | ||
|
||
public ServiceManager(ServiceParams serviceParams) | ||
{ | ||
_company = new Lazy<ICompanyService>(() => new CompanyService(serviceParams)); | ||
_customer = new Lazy<ICustomerService>(() => new CustomerService(serviceParams)); | ||
_employee = new Lazy<IEmployeeService>(() => new EmployeeService(serviceParams)); | ||
_product = new Lazy<IProductService>(() => new ProductService(serviceParams)); | ||
_store = new Lazy<IStoreService>(() => new StoreService(serviceParams)); | ||
} | ||
|
||
public ICompanyService Company => _company.Value; | ||
|
||
public ICustomerService Customer => _customer.Value; | ||
|
||
public IEmployeeService Employee => _employee.Value; | ||
|
||
public IProductService Product => _product.Value; | ||
|
||
public IStoreService Store => _store.Value; | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
Implementations/eShopOnlineBusiness/Parameters/ServiceParams.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,18 @@ | ||
using Contracts.Repositories.Managers; | ||
using Contracts.Utilities.Mapper; | ||
|
||
namespace eShopOnlineBusiness.Parameters | ||
{ | ||
public sealed class ServiceParams | ||
{ | ||
public readonly IRepositoryManager RepositoryManager; | ||
public readonly IMapperService MapperService; | ||
|
||
public ServiceParams(IRepositoryManager repositoryManager, | ||
IMapperService mapperService) | ||
{ | ||
RepositoryManager = repositoryManager; | ||
MapperService = mapperService; | ||
} | ||
} | ||
} |
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,6 @@ | ||
global using Contracts.Business.Entities; | ||
global using Domains.Entities; | ||
global using eShopOnlineBusiness.Abstracts; | ||
global using eShopOnlineBusiness.Parameters; | ||
global using Shared.DTOs.Inputs.FromBody.CreationDtos; | ||
global using Shared.DTOs.Outputs.EntityDtos; |
15 changes: 15 additions & 0 deletions
15
Implementations/eShopOnlineBusiness/eShopOnlineBusiness.csproj
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,15 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net6.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Cores\Contracts.Business\Contracts.Business.csproj" /> | ||
<ProjectReference Include="..\..\Cores\Contracts.Repositories\Contracts.Repositories.csproj" /> | ||
<ProjectReference Include="..\..\Cores\Contracts\Contracts.csproj" /> | ||
</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
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
Oops, something went wrong.