wip trash for
This commit is contained in:
@@ -10,20 +10,16 @@
|
||||
<InternalsVisibleTo Include="CandyHouseWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.2" />
|
||||
<PackageReference Include="PDFsharp-MigraDoc" Version="6.2.0-preview-3" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="9.0.1" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CandyHouseContracts\CandyHouseContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Extensions.Localization.Abstractions">
|
||||
<HintPath>C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\9.0.2\Microsoft.Extensions.Localization.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<ProjectReference Include="..\CandyHouseContratcs\CandyHouseContratcs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
@@ -11,7 +11,7 @@ using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
|
||||
public class ClientBusinessLogicContract(
|
||||
internal class ClientBusinessLogicContract(
|
||||
IClientStorageContract clientStorageContract,
|
||||
ILogger logger,
|
||||
IStringLocalizer<Messages> localizer) : IClientBusinessLogicContract
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
|
||||
public class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : IEmployeeBusinessLogicContract
|
||||
internal class EmployeeBusinessLogicContract(
|
||||
IEmployeeStorageContract employeeStorageContract,
|
||||
ILogger logger,
|
||||
IStringLocalizer<Messages> localizer) : IEmployeeBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IEmployeeStorageContract _employeeStorageContract = employeeStorageContract;
|
||||
@@ -35,30 +33,38 @@ public class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStor
|
||||
{
|
||||
throw new ArgumentNullException(nameof(postId));
|
||||
}
|
||||
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _employeeStorageContract.GetList(onlyActive, postId);
|
||||
}
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployeesByBirthDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
public List<EmployeeDataModel> GetAllEmployeesByBirthDate(DateTime fromDate, DateTime toDate,
|
||||
bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate, toDate);
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate,
|
||||
toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
return _employeeStorageContract.GetList(onlyActive, fromBirthDate: fromDate, toBirthDate: toDate);
|
||||
}
|
||||
|
||||
public List<EmployeeDataModel> GetAllEmployeesByEmploymentDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
public List<EmployeeDataModel> GetAllEmployeesByEmploymentDate(DateTime fromDate, DateTime toDate,
|
||||
bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate, toDate);
|
||||
_logger.LogInformation("GetAllEmployees params: {onlyActive}, {fromDate}, {toDate}", onlyActive, fromDate,
|
||||
toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
return _employeeStorageContract.GetList(onlyActive, fromEmploymentDate: fromDate, toEmploymentDate: toDate);
|
||||
}
|
||||
|
||||
@@ -69,14 +75,19 @@ public class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStor
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _employeeStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
return _employeeStorageContract.GetElementById(data) ??
|
||||
throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
if (Regex.IsMatch(data, @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"))
|
||||
{
|
||||
return _employeeStorageContract.GetElementByEmail(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
return _employeeStorageContract.GetElementByEmail(data) ??
|
||||
throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
return _employeeStorageContract.GetElementByFIO(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
@@ -103,10 +114,12 @@ public class EmployeeBusinessLogicContract(IEmployeeStorageContract employeeStor
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
_employeeStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
|
||||
public class PostBusinessLogicContract(IPostStorageContract postStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : IPostBusinessLogicContract
|
||||
internal class PostBusinessLogicContract(
|
||||
IPostStorageContract postStorageContract,
|
||||
ILogger logger,
|
||||
IStringLocalizer<Messages> localizer) : IPostBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IPostStorageContract _postStorageContract = postStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<PostDataModel> GetAllPosts()
|
||||
{
|
||||
_logger.LogInformation("GetAllPosts");
|
||||
@@ -32,10 +32,12 @@ public class PostBusinessLogicContract(IPostStorageContract postStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(postId));
|
||||
}
|
||||
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _postStorageContract.GetPostWithHistory(postId);
|
||||
}
|
||||
|
||||
@@ -46,10 +48,12 @@ public class PostBusinessLogicContract(IPostStorageContract postStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _postStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
return _postStorageContract.GetElementByName(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
@@ -76,10 +80,12 @@ public class PostBusinessLogicContract(IPostStorageContract postStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
_postStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -90,10 +96,12 @@ public class PostBusinessLogicContract(IPostStorageContract postStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
_postStorageContract.ResElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,26 +1,24 @@
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
|
||||
public class ProductBusinessLogicContract(IProductStorageContract productStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : IProductBusinessLogicContract
|
||||
internal class ProductBusinessLogicContract(
|
||||
IProductStorageContract productStorageContract,
|
||||
ILogger logger,
|
||||
IStringLocalizer<Messages> localizer) : IProductBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IProductStorageContract _productStorageContract = productStorageContract;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<ProductDataModel> GetAllProducts()
|
||||
{
|
||||
_logger.LogInformation("GetAllProducts");
|
||||
@@ -34,10 +32,12 @@ public class ProductBusinessLogicContract(IProductStorageContract productStorage
|
||||
{
|
||||
throw new ArgumentNullException(nameof(productId));
|
||||
}
|
||||
|
||||
if (!productId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field productId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _productStorageContract.GetHistoryByProductId(productId);
|
||||
}
|
||||
|
||||
@@ -48,10 +48,12 @@ public class ProductBusinessLogicContract(IProductStorageContract productStorage
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _productStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
return _productStorageContract.GetElementByName(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
@@ -78,10 +80,12 @@ public class ProductBusinessLogicContract(IProductStorageContract productStorage
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
_productStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
@@ -8,15 +8,17 @@ using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract,ISaleStorageContract saleStorageContract,
|
||||
IPostStorageContract postStorageContract, IEmployeeStorageContract employeeStorageContract, ILogger logger, IConfigurationSalary сonfiguration, IStringLocalizer<Messages> localizer) : ISalaryBusinessLogicContract
|
||||
|
||||
internal class SalaryBusinessLogicContract(
|
||||
ISalaryStorageContract salaryStorageContract,
|
||||
ISaleStorageContract saleStorageContract,
|
||||
IPostStorageContract postStorageContract,
|
||||
IEmployeeStorageContract employeeStorageContract,
|
||||
ILogger logger,
|
||||
IConfigurationSalary сonfiguration,
|
||||
IStringLocalizer<Messages> localizer) : ISalaryBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract = salaryStorageContract;
|
||||
@@ -26,6 +28,7 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
private readonly IConfigurationSalary _salaryConfiguration = сonfiguration;
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
private readonly Lock _lockObject = new();
|
||||
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}", fromDate, toDate);
|
||||
@@ -33,6 +36,7 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
return _salaryStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
@@ -42,15 +46,19 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
if (employeeId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(employeeId));
|
||||
}
|
||||
|
||||
if (!employeeId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field employeeId is not a unique identifier.");
|
||||
}
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, {employeeId}", fromDate, toDate, employeeId);
|
||||
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, {employeeId}", fromDate, toDate,
|
||||
employeeId);
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, employeeId);
|
||||
}
|
||||
|
||||
@@ -58,12 +66,14 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
{
|
||||
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
|
||||
var startDate = new DateTime(date.Year, date.Month, 1, 0, 0, 0, DateTimeKind.Utc);
|
||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month), 23, 59, 59, DateTimeKind.Utc);
|
||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month), 23, 59, 59,
|
||||
DateTimeKind.Utc);
|
||||
var employees = _employeeStorageContract.GetList();
|
||||
foreach (var employee in employees)
|
||||
{
|
||||
var sales = _saleStorageContract.GetList(startDate, finishDate, employeeId: employee.Id);
|
||||
var post = _postStorageContract.GetElementById(employee.PostId) ?? throw new ElementNotFoundException(employee.PostId, _localizer);
|
||||
var post = _postStorageContract.GetElementById(employee.PostId) ??
|
||||
throw new ElementNotFoundException(employee.PostId, _localizer);
|
||||
var salary = post.ConfigurationModel switch
|
||||
{
|
||||
null => 0,
|
||||
@@ -75,7 +85,9 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
_salaryStorageContract.AddElement(new SalaryDataModel(employee.Id, finishDate, salary));
|
||||
}
|
||||
}
|
||||
private double CalculateSalaryForSuperManager(List<SaleDataModel> sales, DateTime startDate, DateTime finishDate, ManagerPostConfiguration config)
|
||||
|
||||
private double CalculateSalaryForSuperManager(List<SaleDataModel> sales, DateTime startDate, DateTime finishDate,
|
||||
ManagerPostConfiguration config)
|
||||
{
|
||||
var calcPercent = 0.0;
|
||||
var dates = new List<DateTime>();
|
||||
@@ -104,19 +116,23 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
double calcBonusTask = 0;
|
||||
try
|
||||
{
|
||||
calcBonusTask = sales.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum).Sum(x => x.Sum) * config.BonusForExtraSales;
|
||||
calcBonusTask = sales.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum).Sum(x => x.Sum) *
|
||||
config.BonusForExtraSales;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in bonus calculation");
|
||||
}
|
||||
|
||||
return config.Rate + calcPercent + calcBonusTask;
|
||||
}
|
||||
|
||||
private double CalculateSalaryForChief(DateTime startDate, DateTime finishDate, BakerPostConfiguration config)
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.Rate + config.PersonalCountTrendPremium * _employeeStorageContract.GetEmployeeTrend(startDate, finishDate);
|
||||
return config.Rate + config.PersonalCountTrendPremium *
|
||||
_employeeStorageContract.GetEmployeeTrend(startDate, finishDate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -124,4 +140,4 @@ public class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageCon
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,21 +1,19 @@
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.Extensions;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseBusinessLogic.Implementations;
|
||||
|
||||
public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : ISaleBusinessLogicContract
|
||||
internal class SaleBusinessLogicContract(
|
||||
ISaleStorageContract saleStorageContract,
|
||||
ILogger logger,
|
||||
IStringLocalizer<Messages> localizer) : ISaleBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
|
||||
@@ -28,6 +26,7 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
return _saleStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
@@ -38,14 +37,17 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
if (employeeId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(employeeId));
|
||||
}
|
||||
|
||||
if (!employeeId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field employeeId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _saleStorageContract.GetList(fromDate, toDate, employeeId: employeeId);
|
||||
}
|
||||
|
||||
@@ -56,14 +58,17 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
if (clientId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(clientId));
|
||||
}
|
||||
|
||||
if (!clientId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field clientId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _saleStorageContract.GetList(fromDate, toDate, clientId: clientId);
|
||||
}
|
||||
|
||||
@@ -74,14 +79,17 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
|
||||
if (productId.IsEmpty())
|
||||
{
|
||||
throw new ArgumentNullException(nameof(productId));
|
||||
}
|
||||
|
||||
if (!productId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field productId is not a unique identifier.");
|
||||
}
|
||||
|
||||
return _saleStorageContract.GetList(fromDate, toDate, productId: productId);
|
||||
}
|
||||
|
||||
@@ -92,10 +100,12 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
return _saleStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
@@ -114,10 +124,12 @@ public class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract,
|
||||
{
|
||||
throw new ArgumentNullException(nameof(id));
|
||||
}
|
||||
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
}
|
||||
|
||||
_saleStorageContract.DelElement(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
using CandyHouseContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.BuisnessLogicContracts;
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface IClientBusinessLogicContract
|
||||
internal interface IClientBusinessLogicContract
|
||||
{
|
||||
List<ClientDataModel> GetAllClients();
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using CandyHouseContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.BuisnessLogicContracts;
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface IEmployeeBusinessLogicContract
|
||||
internal interface IEmployeeBusinessLogicContract
|
||||
{
|
||||
List<EmployeeDataModel> GetAllEmployees(bool onlyActive = true);
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using CandyHouseContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.BuisnessLogicContracts;
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface IPostBusinessLogicContract
|
||||
internal interface IPostBusinessLogicContract
|
||||
{
|
||||
List<PostDataModel> GetAllPosts();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface IProductBusinessLogicContract
|
||||
internal interface IProductBusinessLogicContract
|
||||
{
|
||||
List<ProductDataModel> GetAllProducts();
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
|
||||
public interface IReportContract
|
||||
internal interface IReportContract
|
||||
{
|
||||
Task<List<ProductHistoryPricesDataModel>> GetDataProductHistoryPricesAsync(CancellationToken ct);
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using CandyHouseContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.BuisnessLogicContracts;
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface ISalaryBusinessLogicContract
|
||||
internal interface ISalaryBusinessLogicContract
|
||||
{
|
||||
List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
using CandyHouseContracts.DataModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.BuisnessLogicContracts;
|
||||
namespace CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
public interface ISaleBusinessLogicContract
|
||||
internal interface ISaleBusinessLogicContract
|
||||
{
|
||||
List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -7,33 +7,33 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Abstractions" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="9.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Extensions.Localization.Abstractions">
|
||||
<HintPath>C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App\9.0.2\Microsoft.Extensions.Localization.Abstractions.dll</HintPath>
|
||||
</Reference>
|
||||
<Compile Update="Resources\Messages.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Messages.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Resources\Messages.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Resources\Messages.en-US.resx">
|
||||
<Generator>PublicResXFileCodeGenerator</Generator>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Update="Resources\Messages.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Resources\Messages.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Messages.resx</DependentUpon>
|
||||
</Compile>
|
||||
<InternalsVisibleTo Include="CandyHouseBusinessLogic" />
|
||||
<InternalsVisibleTo Include="CandyHouseDatabase" />
|
||||
<InternalsVisibleTo Include="CandyHouseWebApi" />
|
||||
<InternalsVisibleTo Include="CandyHouseTests" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -14,7 +14,7 @@ using ValidationException = CandyHouseContracts.Exceptions.ValidationException;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class ClientDataModel(string id, string fIO, string phoneNumber, double discountSize) : IValidation
|
||||
internal class ClientDataModel(string id, string fIO, string phoneNumber, double discountSize) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class ClientDiscountDataModel(string clientId, DateTime discountDate, double discountAmount) : IValidation
|
||||
internal class ClientDiscountDataModel(string clientId, DateTime discountDate, double discountAmount) : IValidation
|
||||
{
|
||||
private readonly ClientDataModel? _client;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
internal class EmployeeDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
{
|
||||
private readonly PostDataModel? _post;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class PostDataModel(string postId, string postName, PostType postType, PostConfiguration configuration) : IValidation
|
||||
internal class PostDataModel(string postId, string postName, PostType postType, PostConfiguration configuration) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = postId;
|
||||
public string PostName { get; private set; } = postName;
|
||||
|
||||
@@ -14,7 +14,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class ProductDataModel(string id, string productName, string productDescription, double price, ProductType productType) : IValidation
|
||||
internal class ProductDataModel(string id, string productName, string productDescription, double price, ProductType productType) : IValidation
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
public string ProductName { get; private set; } = productName;
|
||||
|
||||
@@ -11,7 +11,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class ProductHistoryDataModel(string productId, double oldPrice) : IValidation
|
||||
internal class ProductHistoryDataModel(string productId, double oldPrice) : IValidation
|
||||
{
|
||||
private readonly ProductDataModel? _product;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary) : IValidation
|
||||
internal class SalaryDataModel(string employeeId, DateTime salaryDate, double employeeSalary) : IValidation
|
||||
{
|
||||
private readonly EmployeeDataModel? _employee;
|
||||
public string EmployeeId { get; private set; } = employeeId;
|
||||
|
||||
@@ -12,7 +12,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class SaleDataModel : IValidation
|
||||
internal class SaleDataModel : IValidation
|
||||
{
|
||||
private readonly ClientDataModel? _client;
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.DataModels;
|
||||
|
||||
public class SaleProductDataModel(string saleId, string productId, int count, double price) : IValidation
|
||||
internal class SaleProductDataModel(string saleId, string productId, int count, double price) : IValidation
|
||||
{
|
||||
private readonly ProductDataModel? _product;
|
||||
|
||||
|
||||
@@ -8,8 +8,8 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.Exceptions;
|
||||
|
||||
// Refactored to use IStringLocalizer
|
||||
public class ElementDeletedException(string id, IStringLocalizer<Messages> localizer)
|
||||
|
||||
internal class ElementDeletedException(string id, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["ElementDeletedExceptionMessage"], id))
|
||||
{
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
@@ -8,8 +8,8 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.Exceptions;
|
||||
|
||||
// Refactored to use IStringLocalizer
|
||||
public class ElementExistsException(string paramName, string paramValue, IStringLocalizer<Messages> localizer)
|
||||
|
||||
internal class ElementExistsException(string paramName, string paramValue, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["ElementExistsExceptionMessage"], paramValue, paramName))
|
||||
{
|
||||
public string ParamName { get; private set; } = paramName;
|
||||
|
||||
@@ -9,7 +9,7 @@ using CandyHouseContratcs.Resources;
|
||||
namespace CandyHouseContracts.Exceptions;
|
||||
|
||||
// Applying the provided example structure
|
||||
public class ElementNotFoundException(string value, IStringLocalizer<Messages> localizer)
|
||||
internal class ElementNotFoundException(string value, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["ElementNotFoundExceptionMessage"], value))
|
||||
{
|
||||
public string Value { get; private set; } = value;
|
||||
|
||||
@@ -8,8 +8,8 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.Exceptions;
|
||||
|
||||
// Refactored to use IStringLocalizer
|
||||
public class IncorrectDatesException(DateTime start, DateTime end, IStringLocalizer<Messages> localizer)
|
||||
|
||||
internal class IncorrectDatesException(DateTime start, DateTime end, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["IncorrectDatesExceptionMessage"], start, end))
|
||||
{
|
||||
public DateTime StartDate { get; private set; } = start;
|
||||
|
||||
@@ -8,8 +8,8 @@ using CandyHouseContratcs.Resources;
|
||||
|
||||
namespace CandyHouseContracts.Exceptions;
|
||||
|
||||
// Refactored to use IStringLocalizer
|
||||
public class StorageException(Exception ex, IStringLocalizer<Messages> localizer)
|
||||
|
||||
internal class StorageException(Exception ex, IStringLocalizer<Messages> localizer)
|
||||
: Exception(string.Format(localizer["StorageExceptionMessage"], ex.Message), ex)
|
||||
{
|
||||
}
|
||||
@@ -8,7 +8,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace CandyHouseContracts.Infrastructure;
|
||||
|
||||
public interface IValidation
|
||||
internal interface IValidation
|
||||
{
|
||||
void Validate(IStringLocalizer<Messages> localizer);
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ using System;
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
public class Messages {
|
||||
internal class Messages {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface IClientDiscountStorageContract
|
||||
internal interface IClientDiscountStorageContract
|
||||
{
|
||||
List<ClientDiscountDataModel> GetList(DateTime startDate, DateTime endDate, string? clientId = null);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface IClientStorageContract
|
||||
internal interface IClientStorageContract
|
||||
{
|
||||
List<ClientDataModel> GetList();
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface IEmployeeStorageContract
|
||||
internal interface IEmployeeStorageContract
|
||||
{
|
||||
List<EmployeeDataModel> GetList(bool onlyActive = true, string? postId = null, DateTime? fromBirthDate = null,
|
||||
DateTime? toBirthDate = null, DateTime? fromEmploymentDate = null, DateTime? toEmploymentDate = null);
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface IPostStorageContract
|
||||
internal interface IPostStorageContract
|
||||
{
|
||||
List<PostDataModel> GetList();
|
||||
List<PostDataModel> GetPostWithHistory(string postId);
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface IProductStorageContract
|
||||
internal interface IProductStorageContract
|
||||
{
|
||||
List<ProductDataModel> GetList();
|
||||
List<ProductHistoryDataModel> GetHistoryByProductId(string productId);
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface ISalaryStorageContract
|
||||
internal interface ISalaryStorageContract
|
||||
{
|
||||
List<SalaryDataModel> GetList(DateTime? startDate, DateTime? endDate, string? employeeId = null);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseContracts.StoragesContracts;
|
||||
|
||||
public interface ISaleStorageContract
|
||||
internal interface ISaleStorageContract
|
||||
{
|
||||
List<SaleDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string? employeeId = null,
|
||||
string? clientId = null, string? productId = null);
|
||||
|
||||
@@ -8,23 +8,24 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AutoMapper" Version="14.0.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.3">
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.2" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="9.0.2">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Localization.Abstractions" Version="10.0.0-preview.3.25172.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CandyHouseContracts\CandyHouseContracts.csproj" />
|
||||
<ProjectReference Include="..\CandyHouseContratcs\CandyHouseContratcs.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Microsoft.Extensions.Localization.Abstractions" />
|
||||
<InternalsVisibleTo Include="CandyHouseTests" />
|
||||
<InternalsVisibleTo Include="CandyHouseWebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -9,7 +9,7 @@ using Microsoft.Extensions.Localization;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class ClientDiscountStorageContract : IClientDiscountStorageContract
|
||||
internal class ClientDiscountStorageContract : IClientDiscountStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class ClientStorageContract : IClientStorageContract
|
||||
internal class ClientStorageContract : IClientStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class EmployeeStorageContract : IEmployeeStorageContract
|
||||
internal class EmployeeStorageContract : IEmployeeStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class PostStorageContract : IPostStorageContract
|
||||
internal class PostStorageContract : IPostStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -15,7 +15,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class ProductStorageContract : IProductStorageContract
|
||||
internal class ProductStorageContract : IProductStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class SalaryStorageContract : ISalaryStorageContract
|
||||
internal class SalaryStorageContract : ISalaryStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -14,7 +14,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CandyHouseDatabase.Implementations;
|
||||
|
||||
public class SaleStorageContract : ISaleStorageContract
|
||||
internal class SaleStorageContract : ISaleStorageContract
|
||||
{
|
||||
private readonly CandyHouseDbContext _dbContext;
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
using CandyHouseBusinessLogic.Implementations;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseTests.Infrastructure;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
namespace CandyHouseTests.BusinessLogicContractsTests;
|
||||
|
||||
[TestFixture]
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<IsPackable>false</IsPackable>
|
||||
<IsTestProject>true</IsTestProject>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -18,25 +17,25 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="Moq" Version="4.20.72" />
|
||||
<PackageReference Include="NUnit" Version="3.14.0" />
|
||||
<PackageReference Include="NUnit.Analyzers" Version="3.9.0" />
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="coverlet.collector" Version="6.0.2"/>
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="9.0.2"/>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1"/>
|
||||
<PackageReference Include="Moq" Version="4.20.72"/>
|
||||
<PackageReference Include="NUnit" Version="4.2.2"/>
|
||||
<PackageReference Include="NUnit.Analyzers" Version="4.3.0"/>
|
||||
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\CandyHouseBusinessLogic\CandyHouseBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\CandyHouseBusinessLogic\CandyHouseBusinessLogic.csproj"/>
|
||||
<ProjectReference Include="..\CandyHouseContracts\CandyHouseContracts.csproj" />
|
||||
<ProjectReference Include="..\CandyHouseDatabase\CandyHouseDatabase.csproj" />
|
||||
<ProjectReference Include="..\CandyHouseWebApi\CandyHouseWebApi.csproj" />
|
||||
<ProjectReference Include="..\CandyHouseContratcs\CandyHouseContratcs.csproj"/>
|
||||
<ProjectReference Include="..\CandyHouseDatabase\CandyHouseDatabase.csproj"/>
|
||||
<ProjectReference Include="..\CandyHouseWebApi\CandyHouseWebApi.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Using Include="NUnit.Framework" />
|
||||
<Using Include="NUnit.Framework"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -30,9 +30,8 @@ internal abstract class BaseLocalizationControllerTest
|
||||
protected static readonly JsonSerializerOptions
|
||||
JsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
private static string _manufacturerId;
|
||||
private static string _buyerId;
|
||||
private static string _workerId;
|
||||
private static string _clientId;
|
||||
private static string _employeeId;
|
||||
private static string _productId;
|
||||
private static string _postId;
|
||||
|
||||
@@ -70,10 +69,10 @@ internal abstract class BaseLocalizationControllerTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_buyerId = CandyHouseDbContext.InsertClientToDatabaseAndReturn(fio: "Client", phoneNumber: "+6-666-666-66-66")
|
||||
_clientId = CandyHouseDbContext.InsertClientToDatabaseAndReturn(fio: "Client", phoneNumber: "+6-666-666-66-66")
|
||||
.Id;
|
||||
_workerId = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "Employee").Id;
|
||||
_productId = CandyHouseDbContext.InsertProductToDatabaseAndReturn(_manufacturerId, productName: "Product").Id;
|
||||
_employeeId = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "Employee").Id;
|
||||
_productId = CandyHouseDbContext.InsertProductToDatabaseAndReturn(productName: "Product").Id;
|
||||
_postId = CandyHouseDbContext.InsertPostToDatabaseAndReturn(postName: "Post").PostId;
|
||||
}
|
||||
|
||||
@@ -116,12 +115,12 @@ internal abstract class BaseLocalizationControllerTest
|
||||
public async Task LoadSales_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var worker = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn();
|
||||
var employee = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn();
|
||||
var product1 = CandyHouseDbContext.InsertProductToDatabaseAndReturn(productName: "name 1");
|
||||
var product2 = CandyHouseDbContext.InsertProductToDatabaseAndReturn(productName: "name 2");
|
||||
CandyHouseDbContext.InsertSaleToDatabaseAndReturn(worker.Id,
|
||||
CandyHouseDbContext.InsertSaleToDatabaseAndReturn(employee.Id,
|
||||
products: [(product1.Id, 10, 1.1), (product2.Id, 10, 1.1)]);
|
||||
CandyHouseDbContext.InsertSaleToDatabaseAndReturn(worker.Id, products: [(product1.Id, 10, 1.1)]);
|
||||
CandyHouseDbContext.InsertSaleToDatabaseAndReturn(employee.Id, products: [(product1.Id, 10, 1.1)]);
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync(
|
||||
$"/api/report/loadsales?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}");
|
||||
@@ -134,19 +133,19 @@ internal abstract class BaseLocalizationControllerTest
|
||||
{
|
||||
//Arrange
|
||||
var post = CandyHouseDbContext.InsertPostToDatabaseAndReturn();
|
||||
var worker1 = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "fio 1", postId: post.PostId)
|
||||
var employee1 = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "fio 1", postId: post.PostId)
|
||||
.AddPost(post);
|
||||
var worker2 = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "fio 2", postId: post.PostId)
|
||||
var employee2 = CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(fio: "fio 2", postId: post.PostId)
|
||||
.AddPost(post);
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, employeeSalary: 100,
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(employee1.Id, employeeSalary: 100,
|
||||
salaryDate: DateTime.UtcNow.AddDays(-10));
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, employeeSalary: 1000,
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(employee1.Id, employeeSalary: 1000,
|
||||
salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, employeeSalary: 200,
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(employee1.Id, employeeSalary: 200,
|
||||
salaryDate: DateTime.UtcNow.AddDays(5));
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(worker2.Id, employeeSalary: 500,
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(employee2.Id, employeeSalary: 500,
|
||||
salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(worker2.Id, employeeSalary: 300,
|
||||
CandyHouseDbContext.InsertSalaryToDatabaseAndReturn(employee2.Id, employeeSalary: 300,
|
||||
salaryDate: DateTime.UtcNow.AddDays(-3));
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync(
|
||||
@@ -184,12 +183,11 @@ internal abstract class BaseLocalizationControllerTest
|
||||
|
||||
protected abstract string MessageElementNotFound();
|
||||
|
||||
[TestCase("buyers")]
|
||||
[TestCase("manufacturers")]
|
||||
[TestCase("clients")]
|
||||
[TestCase("posts")]
|
||||
[TestCase("products/getrecord")]
|
||||
[TestCase("sales/getrecord")]
|
||||
[TestCase("workers/getrecord")]
|
||||
[TestCase("employees/getrecord")]
|
||||
public async Task Api_GetElement_NotFound_Test(string path)
|
||||
{
|
||||
//Act
|
||||
@@ -212,7 +210,7 @@ internal abstract class BaseLocalizationControllerTest
|
||||
var model = CreateClientBindingModel();
|
||||
CandyHouseDbContext.InsertClientToDatabaseAndReturn(model.Id);
|
||||
return model;
|
||||
}, "buyers");
|
||||
}, "clients");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreatePostModel();
|
||||
@@ -221,16 +219,16 @@ internal abstract class BaseLocalizationControllerTest
|
||||
}, "posts");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateProductModel(_manufacturerId);
|
||||
CandyHouseDbContext.InsertProductToDatabaseAndReturn(_manufacturerId, model.Id);
|
||||
var model = CreateProductModel();
|
||||
CandyHouseDbContext.InsertProductToDatabaseAndReturn(model.Id);
|
||||
return model;
|
||||
}, "products/register");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateEmployeeModel(_manufacturerId);
|
||||
var model = CreateEmployeeModel(_postId);
|
||||
CandyHouseDbContext.InsertEmployeeToDatabaseAndReturn(model.Id, postId: _postId);
|
||||
return model;
|
||||
}, "workers/register");
|
||||
}, "employees/register");
|
||||
}
|
||||
|
||||
protected abstract string MessageElementExists();
|
||||
@@ -289,15 +287,15 @@ internal abstract class BaseLocalizationControllerTest
|
||||
Price = price
|
||||
};
|
||||
|
||||
private static SaleBindingModel CreateSaleModel(string workerId, string? buyerId, string productId,
|
||||
private static SaleBindingModel CreateSaleModel(string employeeId, string? clientId, string productId,
|
||||
string? id = null, DiscountType discountType = DiscountType.OnSale, int count = 1, double price = 1.1)
|
||||
{
|
||||
var saleId = id ?? Guid.NewGuid().ToString();
|
||||
return new()
|
||||
{
|
||||
Id = saleId,
|
||||
EmployeeId = workerId,
|
||||
ClientId = buyerId,
|
||||
EmployeeId = employeeId,
|
||||
ClientId = clientId,
|
||||
DiscountType = (int)discountType,
|
||||
Products =
|
||||
[
|
||||
|
||||
@@ -7,5 +7,5 @@ internal class RuRuTests : BaseLocalizationControllerTest
|
||||
|
||||
protected override string MessageElementExists() => "Уже существует элемент со значением";
|
||||
|
||||
protected override string MessageElementNotFound() => "Не найден элемент по данным";
|
||||
protected override string MessageElementNotFound() => "Не найден элемент по данным: {0}";
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.BindingModels;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.ViewModels;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.BindingModels;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.ViewModels;
|
||||
@@ -10,6 +9,7 @@ using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseWebApi.Adapters;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.BindingModels;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.ViewModels;
|
||||
@@ -10,6 +9,7 @@ using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Text.Json;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseWebApi.Adapters;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.BindingModels;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using AutoMapper;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.ViewModels;
|
||||
using CandyHouseContracts.DataModels;
|
||||
@@ -9,6 +8,7 @@ using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseWebApi.Adapters;
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.AdapterContracts.OperationResponses;
|
||||
using CandyHouseContracts.BindingModels;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.DataModels;
|
||||
using CandyHouseContracts.Exceptions;
|
||||
using CandyHouseContracts.ViewModels;
|
||||
@@ -10,6 +9,7 @@ using CandyHouseContratcs.Resources;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using CandyHouseContracts.BusinessLogicContracts;
|
||||
|
||||
namespace CandyHouseWebApi.Adapters;
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System.Globalization;
|
||||
using CandyHouseBusinessLogic.Implementations;
|
||||
using CandyHouseContracts.AdapterContracts;
|
||||
using CandyHouseContracts.BuisnessLogicContracts;
|
||||
using CandyHouseContracts.Infrastructure;
|
||||
using CandyHouseContracts.StoragesContracts;
|
||||
using CandyHouseDatabase;
|
||||
@@ -58,6 +57,21 @@ builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddLocalization();
|
||||
builder.Services.Configure<RequestLocalizationOptions>(
|
||||
options =>
|
||||
{
|
||||
var supportedCultures = new List<CultureInfo>
|
||||
{
|
||||
new("en-US"),
|
||||
new("ru-RU")
|
||||
};
|
||||
options.DefaultRequestCulture = new RequestCulture(culture: "ru-RU",
|
||||
uiCulture: "ru-RU");
|
||||
options.SupportedCultures = supportedCultures;
|
||||
options.SupportedUICultures = supportedCultures;
|
||||
});
|
||||
|
||||
builder.Services.AddSingleton<IConfigurationDatabase, ConfigurationDatabase>();
|
||||
|
||||
builder.Services.AddTransient<IClientBusinessLogicContract, ClientBusinessLogicContract>();
|
||||
@@ -94,20 +108,7 @@ builder.Services.AddTransient<IReportAdapter, ReportAdapter>();
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
builder.Services.AddOpenApi();
|
||||
|
||||
builder.Services.AddLocalization();
|
||||
builder.Services.Configure<RequestLocalizationOptions>(
|
||||
options =>
|
||||
{
|
||||
var supportedCultures = new List<CultureInfo>
|
||||
{
|
||||
new("en-US"),
|
||||
new("ru-RU")
|
||||
};
|
||||
options.DefaultRequestCulture = new RequestCulture(culture: "ru-RU",
|
||||
uiCulture: "ru-RU");
|
||||
options.SupportedCultures = supportedCultures;
|
||||
options.SupportedUICultures = supportedCultures;
|
||||
});
|
||||
|
||||
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
Reference in New Issue
Block a user