Compare commits
10 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7b9beba3a3 | |||
| 5ba7478569 | |||
| 80d515ad4f | |||
| 69ed258009 | |||
| 8d19cd1280 | |||
| 658d4909e6 | |||
| cafccb31a9 | |||
| c475b16143 | |||
| 6622397eb5 | |||
| aed07873eb |
@@ -1,25 +1,28 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
internal class PostBusinessLogicContract(IPostStorageContract postStorageContract, ILogger logger) : 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");
|
||||
return _postStorageContract.GetList() ?? throw new
|
||||
NullListException();
|
||||
return _postStorageContract.GetList();
|
||||
}
|
||||
|
||||
public List<PostDataModel> GetAllDataOfPost(string postId)
|
||||
@@ -33,7 +36,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
}
|
||||
return _postStorageContract.GetPostWithHistory(postId) ?? throw new NullListException();
|
||||
return _postStorageContract.GetPostWithHistory(postId);
|
||||
}
|
||||
|
||||
public PostDataModel GetPostByData(string data)
|
||||
@@ -46,10 +49,10 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _postStorageContract.GetElementById(data) ?? throw new
|
||||
ElementNotFoundException(data);
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _postStorageContract.GetElementByName(data) ?? throw new
|
||||
ElementNotFoundException(data);
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertPost(PostDataModel postDataModel)
|
||||
@@ -57,7 +60,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(postDataModel));
|
||||
ArgumentNullException.ThrowIfNull(postDataModel);
|
||||
postDataModel.Validate();
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.AddElement(postDataModel);
|
||||
}
|
||||
public void UpdatePost(PostDataModel postDataModel)
|
||||
@@ -65,7 +68,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(postDataModel));
|
||||
ArgumentNullException.ThrowIfNull(postDataModel);
|
||||
postDataModel.Validate();
|
||||
postDataModel.Validate(_localizer);
|
||||
_postStorageContract.UpdElement(postDataModel);
|
||||
}
|
||||
public void DeletePost(string id)
|
||||
@@ -77,7 +80,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "id"));
|
||||
}
|
||||
_postStorageContract.DelElement(id);
|
||||
}
|
||||
@@ -90,7 +93,7 @@ internal class PostBusinessLogicContract(IPostStorageContract postStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "id"));
|
||||
}
|
||||
_postStorageContract.ResElement(id);
|
||||
}
|
||||
|
||||
@@ -5,20 +5,23 @@ using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
internal class ProductBusinessLogicContract(IProductStorageContract productStorageContract, ILogger logger) : 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(bool onlyActive)
|
||||
{
|
||||
_logger.LogInformation("GetAllProducts params: {onlyActive}", onlyActive);
|
||||
return _productStorageContract.GetList(onlyActive) ?? throw new
|
||||
NullListException();
|
||||
return _productStorageContract.GetList(onlyActive);
|
||||
}
|
||||
|
||||
public List<ProductHistoryDataModel> GetProductHistoryByProduct(string productId)
|
||||
@@ -32,7 +35,7 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora
|
||||
{
|
||||
throw new ValidationException("The value in the field productId is not a unique identifier.");
|
||||
}
|
||||
return _productStorageContract.GetHistoryByProductId(productId) ?? throw new NullListException();
|
||||
return _productStorageContract.GetHistoryByProductId(productId);
|
||||
}
|
||||
|
||||
public ProductDataModel GetProductByData(string data)
|
||||
@@ -45,10 +48,10 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _productStorageContract.GetElementById(data) ?? throw
|
||||
new ElementNotFoundException(data);
|
||||
new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _productStorageContract.GetElementByName(data) ?? throw new
|
||||
ElementNotFoundException(data);
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertProduct(ProductDataModel productDataModel)
|
||||
@@ -56,7 +59,7 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(productDataModel));
|
||||
ArgumentNullException.ThrowIfNull(productDataModel);
|
||||
productDataModel.Validate();
|
||||
productDataModel.Validate(_localizer);
|
||||
_productStorageContract.AddElement(productDataModel);
|
||||
|
||||
}
|
||||
@@ -66,7 +69,7 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(productDataModel));
|
||||
ArgumentNullException.ThrowIfNull(productDataModel);
|
||||
productDataModel.Validate();
|
||||
productDataModel.Validate(_localizer);
|
||||
_productStorageContract.UpdElement(productDataModel);
|
||||
}
|
||||
|
||||
@@ -79,7 +82,7 @@ internal class ProductBusinessLogicContract(IProductStorageContract productStora
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "id"));
|
||||
}
|
||||
_productStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -1,29 +1,47 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_BusinessLogics.OfficePackage;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
public class ReportContract(IProductStorageContract productStorageContract, ISaleStorageContract saleStorageContract, ISalaryStorageContract salaryStorageContract, BaseWordBuilder baseWordBuilder, BaseExcelBuilder baseExcelBuilder, BasePdfBuilder basePdfBuilder, ILogger logger) : IReportContract
|
||||
internal class ReportContract : IReportContract
|
||||
{
|
||||
private readonly IProductStorageContract _productStorageContract = productStorageContract;
|
||||
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract = salaryStorageContract;
|
||||
private readonly BaseWordBuilder _baseWordBuilder = baseWordBuilder;
|
||||
private readonly BaseExcelBuilder _baseExcelBuilder = baseExcelBuilder;
|
||||
private readonly BasePdfBuilder _basePdfBuilder = basePdfBuilder;
|
||||
private readonly ILogger _logger = logger;
|
||||
private readonly IProductStorageContract _productStorageContract;
|
||||
private readonly ISaleStorageContract _saleStorageContract;
|
||||
private readonly ISalaryStorageContract _salaryStorageContract;
|
||||
private readonly BaseWordBuilder _baseWordBuilder;
|
||||
private readonly BaseExcelBuilder _baseExcelBuilder;
|
||||
private readonly BasePdfBuilder _basePdfBuilder;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
internal static readonly string[] documentHeader = ["Название продукта", "Старая цена", "Дата"];
|
||||
internal static readonly string[] tableHeader = ["Дата", "Сумма", "Скидка", "Товар", "Кол-во"];
|
||||
public readonly string[] _documentHeader;
|
||||
public readonly string[] _tableHeader;
|
||||
|
||||
public ReportContract(IProductStorageContract productStorageContract, ISaleStorageContract saleStorageContract, ISalaryStorageContract salaryStorageContract, BaseWordBuilder baseWordBuilder, BaseExcelBuilder baseExcelBuilder, BasePdfBuilder basePdfBuilder, ILogger logger, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_productStorageContract = productStorageContract;
|
||||
_saleStorageContract = saleStorageContract;
|
||||
_salaryStorageContract = salaryStorageContract;
|
||||
_baseWordBuilder = baseWordBuilder;
|
||||
_baseExcelBuilder = baseExcelBuilder;
|
||||
_basePdfBuilder = basePdfBuilder;
|
||||
_logger = logger;
|
||||
_localizer = localizer;
|
||||
_documentHeader = [_localizer["DocumentDocCaptionProduct"], _localizer["DocumentDocCaptionOldPrice"], _localizer["DocumentDocCaptionDate"]];
|
||||
_tableHeader = [_localizer["DocumentExcelCaptionDate"], _localizer["DocumentExcelCaptionSum"]
|
||||
, _localizer["DocumentExcelCaptionProduct"], _localizer["DocumentExcelCaptionCount"]];
|
||||
}
|
||||
|
||||
public Task<List<ProductAndProductHistoryDataModel>> GetDataProductsByHistoryAsync(CancellationToken ct)
|
||||
{
|
||||
_logger.LogInformation("Get data ProductsByManufacturer");
|
||||
_logger.LogInformation("Get data ProductsByHistory");
|
||||
return GetProductsHistoriesAsync(ct);
|
||||
}
|
||||
|
||||
@@ -37,15 +55,15 @@ public class ReportContract(IProductStorageContract productStorageContract, ISal
|
||||
var data = await GetProductsHistoriesAsync(ct) ?? throw new InvalidOperationException("No found data");
|
||||
|
||||
return _baseWordBuilder
|
||||
.AddHeader("История продуктов")
|
||||
.AddParagraph($"Сформировано на дату {DateTime.Now}")
|
||||
.AddHeader(_localizer["DocumentDocHeader"])
|
||||
.AddParagraph(string.Format(_localizer["DocumentDocSubHeader"], DateTime.Now))
|
||||
.AddTable(
|
||||
[3000, 3000, 3000],
|
||||
[.. new List<string[]>() { documentHeader }
|
||||
.Union(data.SelectMany(x =>
|
||||
[.. new List<string[]>() { _documentHeader }
|
||||
.Union([.. data.SelectMany(x =>
|
||||
(new List<string[]>() { new[] { x.ProductName, "", "" } })
|
||||
.Union(x.Histories.Zip(x.Data, (price, date) => new[] { "", price, date }))
|
||||
).ToList())
|
||||
)])
|
||||
])
|
||||
.Build();
|
||||
}
|
||||
@@ -54,7 +72,7 @@ public class ReportContract(IProductStorageContract productStorageContract, ISal
|
||||
{
|
||||
if (dateStart.IsDateNotOlder(dateFinish))
|
||||
{
|
||||
throw new IncorrectDatesException(dateStart, dateFinish);
|
||||
throw new IncorrectDatesException(dateStart, dateFinish, _localizer);
|
||||
}
|
||||
return [.. (await _saleStorageContract.GetListAsync(dateStart,
|
||||
dateFinish, ct)).OrderBy(x => x.SaleDate)];
|
||||
@@ -68,44 +86,54 @@ public class ReportContract(IProductStorageContract productStorageContract, ISal
|
||||
|
||||
public async Task<Stream> CreateDocumentSalesByPeriodAsync(DateTime dateStart, DateTime dateFinish, CancellationToken ct)
|
||||
{
|
||||
string[] tableHeader1 = ["Сотрудник", "Дата", "Сумма", "Товар", "Кол-во"];
|
||||
|
||||
_logger.LogInformation("Create report SalesByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
var data = await GetDataBySalesAsync(dateStart, dateFinish, ct) ?? throw new InvalidOperationException("No found data");
|
||||
|
||||
// Создаем список строк таблицы
|
||||
var tableRows = new List<string[]>
|
||||
{
|
||||
tableHeader1
|
||||
};
|
||||
{
|
||||
_tableHeader
|
||||
};
|
||||
|
||||
// Добавляем данные
|
||||
foreach (var sale in data)
|
||||
{
|
||||
// Основная строка продажи
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
sale.WorkerFIO ?? "",
|
||||
sale.SaleDate.ToShortDateString(),
|
||||
sale.Sum.ToString("N2"),
|
||||
"", ""
|
||||
"", // Пустое место для названия продукта
|
||||
"" // Пустое место для количества
|
||||
});
|
||||
|
||||
// Строки для каждого продукта
|
||||
foreach (var product in sale.Products ?? Enumerable.Empty<ProductForSaleDataModel>())
|
||||
{
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
"", "", "", product.ProductName, product.Count.ToString("N2")
|
||||
"", // Пустая дата
|
||||
"", // Пустая сумма
|
||||
product.ProductName,
|
||||
product.Count.ToString("N2")
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Добавляем итоговую строку
|
||||
tableRows.Add(new string[]
|
||||
{
|
||||
"Всего", "", data.Sum(x => x.Sum).ToString("N2"), "", ""
|
||||
"Всего",
|
||||
data.Sum(x => x.Sum).ToString("N2"),
|
||||
"",
|
||||
""
|
||||
});
|
||||
|
||||
return _baseExcelBuilder
|
||||
.AddHeader("Продажи за период", 0, 5)
|
||||
.AddParagraph($"с {dateStart.ToShortDateString()} по {dateFinish.ToShortDateString()}", 2)
|
||||
.AddTable([15, 15, 10, 25, 10], tableRows)
|
||||
.AddHeader(_localizer["DocumentExcelHeader"], 0, 4)
|
||||
.AddParagraph(string.Format(_localizer["DocumentExcelSubHeader"],
|
||||
dateStart.ToLocalTime().ToShortDateString(),
|
||||
dateFinish.ToLocalTime().ToShortDateString()), 2)
|
||||
.AddTable([15, 15, 40, 15], tableRows)
|
||||
.Build();
|
||||
}
|
||||
|
||||
@@ -119,7 +147,7 @@ public class ReportContract(IProductStorageContract productStorageContract, ISal
|
||||
{
|
||||
if (dateStart.IsDateNotOlder(dateFinish))
|
||||
{
|
||||
throw new IncorrectDatesException(dateStart, dateFinish);
|
||||
throw new IncorrectDatesException(dateStart, dateFinish, _localizer);
|
||||
}
|
||||
return [.. (await _salaryStorageContract.GetListAsync(dateStart, dateFinish, ct))
|
||||
.GroupBy(x => x.WorkerId)
|
||||
@@ -137,8 +165,8 @@ public class ReportContract(IProductStorageContract productStorageContract, ISal
|
||||
_logger.LogInformation("Create report SalaryByPeriod from {dateStart} to {dateFinish}", dateStart, dateFinish);
|
||||
var data = await GetDataBySalaryAsync(dateStart, dateFinish, ct) ?? throw new InvalidOperationException("No found data");
|
||||
return _basePdfBuilder
|
||||
.AddHeader("Зарплатная ведомость")
|
||||
.AddParagraph($"за период с {dateStart.ToShortDateString()} по {dateFinish.ToShortDateString()}")
|
||||
.AddHeader(_localizer["DocumentPdfHeader"])
|
||||
.AddParagraph(string.Format(_localizer["DocumentPdfSubHeader"], dateStart.ToLocalTime().ToShortDateString(), dateFinish.ToLocalTime().ToShortDateString()))
|
||||
.AddPieChart("Начисления", [.. data.Select(x => (x.WorkerFIO, x.TotalSalary))])
|
||||
.Build();
|
||||
}
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract, ISaleStorageContract saleStorageContract, IPostStorageContract postStorageContract, IWorkerStorageContract workerStorageContract, ILogger logger, IConfigurationSalary сonfiguration) : ISalaryBusinessLogicContract
|
||||
internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageContract, ISaleStorageContract saleStorageContract, IPostStorageContract postStorageContract, IWorkerStorageContract workerStorageContract, ILogger logger, IConfigurationSalary сonfiguration, IStringLocalizer<Messages> localizer) : ISalaryBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
|
||||
@@ -23,6 +25,8 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
|
||||
private readonly IConfigurationSalary _salaryConfiguration = сonfiguration;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
private readonly Lock _lockObject = new();
|
||||
|
||||
|
||||
@@ -31,17 +35,16 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}", fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _salaryStorageContract.GetList(fromDate, toDate) ?? throw new
|
||||
NullListException();
|
||||
return _salaryStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
public List<SalaryDataModel> GetAllSalariesByPeriodByWorker(DateTime fromDate, DateTime toDate, string workerId)
|
||||
{
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (workerId.IsEmpty())
|
||||
{
|
||||
@@ -49,23 +52,22 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
}
|
||||
if (!workerId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field workerId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "workerId"));
|
||||
}
|
||||
_logger.LogInformation("GetAllSalaries params: {fromDate}, {toDate}, { workerId}", fromDate, toDate, workerId);
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, workerId) ??
|
||||
throw new NullListException();
|
||||
return _salaryStorageContract.GetList(fromDate, toDate, workerId);
|
||||
}
|
||||
|
||||
public void CalculateSalaryByMounth(DateTime date)
|
||||
{
|
||||
_logger.LogInformation("CalculateSalaryByMounth: {date}", date);
|
||||
var startDate = new DateTime(date.Year, date.Month, 1);
|
||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month));
|
||||
var workers = _workerStorageContract.GetList() ?? throw new NullListException();
|
||||
var startDate = new DateTime(date.Year, date.Month, 1).ToUniversalTime();
|
||||
var finishDate = new DateTime(date.Year, date.Month, DateTime.DaysInMonth(date.Year, date.Month)).ToUniversalTime();
|
||||
var workers = _workerStorageContract.GetList();
|
||||
foreach (var worker in workers)
|
||||
{
|
||||
var sales = _saleStorageContract.GetList(startDate, finishDate, workerId: worker.Id) ?? throw new NullListException();
|
||||
var post = _postStorageContract.GetElementById(worker.PostId) ?? throw new NullListException();
|
||||
var sales = _saleStorageContract.GetList(startDate, finishDate, workerId: worker.Id);
|
||||
var post = _postStorageContract.GetElementById(worker.PostId);
|
||||
var salary = post.ConfigurationModel switch
|
||||
{
|
||||
null => 0,
|
||||
@@ -80,55 +82,54 @@ internal class SalaryBusinessLogicContract(ISalaryStorageContract salaryStorageC
|
||||
|
||||
private double CalculateSalaryForCashier(List<SaleDataModel> sales, DateTime startDate, DateTime finishDate, CashierPostConfiguration config)
|
||||
{
|
||||
var options = new ParallelOptions { MaxDegreeOfParallelism = _salaryConfiguration.MaxThreads };
|
||||
var calcPercent = 0.0;
|
||||
var days = new List<DateTime>();
|
||||
for (var date = startDate; date < finishDate; date = date.AddDays(1))
|
||||
var days = (finishDate - startDate).Days;
|
||||
var dates = Enumerable.Range(0, days)
|
||||
.Select(offset => startDate.AddDays(offset))
|
||||
.ToList();
|
||||
|
||||
var parallelOptions = new ParallelOptions
|
||||
{
|
||||
days.Add(date);
|
||||
}
|
||||
Parallel.ForEach(days, options, date =>
|
||||
MaxDegreeOfParallelism = _salaryConfiguration.MaxThreads
|
||||
};
|
||||
|
||||
Parallel.ForEach(dates, parallelOptions, date =>
|
||||
{
|
||||
var salesInDay = sales
|
||||
.Where(x => x.SaleDate >= date && x.SaleDate <= date.AddDays(1)).ToArray();
|
||||
if (salesInDay.Length > 0)
|
||||
var salesInDay = sales.Where(x => x.SaleDate.Date == date.Date).ToArray();
|
||||
if (salesInDay.Length == 0) return;
|
||||
|
||||
double dailySum = salesInDay.Sum(x => x.Sum);
|
||||
double averageSale = dailySum / salesInDay.Length;
|
||||
|
||||
lock (_lockObject)
|
||||
{
|
||||
lock (_lockObject)
|
||||
{
|
||||
calcPercent += (salesInDay.Sum(x => x.Sum) / salesInDay.Length) * config.SalePercent;
|
||||
}
|
||||
calcPercent += averageSale * config.SalePercent;
|
||||
}
|
||||
});
|
||||
var calcBonusTask = Task.Run(() =>
|
||||
{
|
||||
return sales.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum).Sum(x => x.Sum) * config.BonusForExtraSales;
|
||||
});
|
||||
|
||||
double bonus = 0;
|
||||
try
|
||||
{
|
||||
calcBonusTask.Wait();
|
||||
bonus = sales.Where(x => x.Sum > _salaryConfiguration.ExtraSaleSum)
|
||||
.Sum(x => x.Sum) * config.BonusForExtraSales;
|
||||
}
|
||||
catch (AggregateException agEx)
|
||||
catch (Exception ex)
|
||||
{
|
||||
foreach (var ex in agEx.InnerExceptions)
|
||||
{
|
||||
_logger.LogError(ex, "Error in the cashier payroll process");
|
||||
}
|
||||
return 0;
|
||||
_logger.LogError(ex, "Error in bonus calculation");
|
||||
}
|
||||
return config.Rate + calcPercent + calcBonusTask.Result;
|
||||
}
|
||||
|
||||
return config.Rate + calcPercent + bonus;
|
||||
}
|
||||
private double CalculateSalaryForSupervisor(DateTime startDate, DateTime finishDate, SupervisorPostConfiguration config)
|
||||
{
|
||||
try
|
||||
{
|
||||
return config.Rate + config.PersonalCountTrendPremium *
|
||||
_workerStorageContract.GetWorkerTrend(startDate, finishDate);
|
||||
return config.Rate + config.PersonalCountTrendPremium * _workerStorageContract.GetWorkerTrend(startDate, finishDate);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Error in the supervisor payroll process");
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,31 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, ILogger logger) : ISaleBusinessLogicContract
|
||||
internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : ISaleBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
|
||||
private readonly ISaleStorageContract _saleStorageContract = saleStorageContract;
|
||||
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
_logger.LogInformation("GetAllSales params: {fromDate}, {toDate}", fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate) ?? throw new
|
||||
NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate);
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByWorkerByPeriod(string workerId,
|
||||
@@ -31,7 +34,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("GetAllSales params: {workerId}, {fromDate}, { toDate}", workerId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (workerId.IsEmpty())
|
||||
{
|
||||
@@ -39,9 +42,9 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!workerId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field workerId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "workerId"));
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate, workerId: workerId) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate, workerId: workerId);
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetAllSalesByProductByPeriod(string productId, DateTime fromDate, DateTime toDate)
|
||||
@@ -49,7 +52,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("GetAllSales params: {productId}, {fromDate}, { toDate}", productId, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
if (productId.IsEmpty())
|
||||
{
|
||||
@@ -57,9 +60,9 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!productId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field productId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "productId"));
|
||||
}
|
||||
return _saleStorageContract.GetList(fromDate, toDate, productId: productId) ?? throw new NullListException();
|
||||
return _saleStorageContract.GetList(fromDate, toDate, productId: productId);
|
||||
}
|
||||
|
||||
public SaleDataModel GetSaleByData(string data)
|
||||
@@ -71,10 +74,10 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!data.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "data"));
|
||||
}
|
||||
return _saleStorageContract.GetElementById(data) ?? throw new
|
||||
ElementNotFoundException(data);
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertSale(SaleDataModel saleDataModel)
|
||||
@@ -82,7 +85,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(saleDataModel));
|
||||
ArgumentNullException.ThrowIfNull(saleDataModel);
|
||||
saleDataModel.Validate();
|
||||
saleDataModel.Validate(_localizer);
|
||||
_saleStorageContract.AddElement(saleDataModel);
|
||||
}
|
||||
|
||||
@@ -95,7 +98,7 @@ internal class SaleBusinessLogicContract(ISaleStorageContract saleStorageContrac
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "id"));
|
||||
}
|
||||
_saleStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace North_Bridge_BusinessLogics.Implementations;
|
||||
|
||||
internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageContract, ILogger logger) : IWorkerBusinessLogicContract
|
||||
internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageContract, ILogger logger, IStringLocalizer<Messages> localizer) : IWorkerBusinessLogicContract
|
||||
{
|
||||
private readonly ILogger _logger = logger;
|
||||
|
||||
private readonly IWorkerStorageContract _workerStorageContract = workerStorageContract;
|
||||
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer = localizer;
|
||||
|
||||
|
||||
public List<WorkerDataModel> GetAllWorkers(bool onlyActive = true)
|
||||
{
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}", onlyActive);
|
||||
return _workerStorageContract.GetList(onlyActive) ?? throw new NullListException();
|
||||
return _workerStorageContract.GetList(onlyActive);
|
||||
}
|
||||
|
||||
public List<WorkerDataModel> GetAllWorkersByPost(string postId, bool
|
||||
@@ -30,9 +35,9 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
}
|
||||
if (!postId.IsGuid())
|
||||
{
|
||||
throw new ValidationException("The value in the field postId is not a unique identifier.");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, postId) ?? throw new NullListException();
|
||||
return _workerStorageContract.GetList(onlyActive, postId);
|
||||
}
|
||||
|
||||
public List<WorkerDataModel> GetAllWorkersByBirthDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
@@ -40,10 +45,10 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate}", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, fromBirthDate:
|
||||
fromDate, toBirthDate: toDate) ?? throw new NullListException();
|
||||
fromDate, toBirthDate: toDate);
|
||||
}
|
||||
|
||||
public List<WorkerDataModel> GetAllWorkersByEmploymentDate(DateTime fromDate, DateTime toDate, bool onlyActive = true)
|
||||
@@ -51,10 +56,10 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
_logger.LogInformation("GetAllWorkers params: {onlyActive}, { fromDate}, { toDate}", onlyActive, fromDate, toDate);
|
||||
if (fromDate.IsDateNotOlder(toDate))
|
||||
{
|
||||
throw new IncorrectDatesException(fromDate, toDate);
|
||||
throw new IncorrectDatesException(fromDate, toDate, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetList(onlyActive, fromEmploymentDate:
|
||||
fromDate, toEmploymentDate: toDate) ?? throw new NullListException();
|
||||
fromDate, toEmploymentDate: toDate);
|
||||
}
|
||||
|
||||
public WorkerDataModel GetWorkerByData(string data)
|
||||
@@ -67,10 +72,10 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
if (data.IsGuid())
|
||||
{
|
||||
return _workerStorageContract.GetElementById(data) ?? throw
|
||||
new ElementNotFoundException(data);
|
||||
new ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
return _workerStorageContract.GetElementByFIO(data) ?? throw new
|
||||
ElementNotFoundException(data);
|
||||
ElementNotFoundException(data, _localizer);
|
||||
}
|
||||
|
||||
public void InsertWorker(WorkerDataModel workerDataModel)
|
||||
@@ -78,7 +83,7 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
_logger.LogInformation("New data: {json}",
|
||||
JsonSerializer.Serialize(workerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(workerDataModel);
|
||||
workerDataModel.Validate();
|
||||
workerDataModel.Validate(_localizer);
|
||||
_workerStorageContract.AddElement(workerDataModel);
|
||||
}
|
||||
|
||||
@@ -87,7 +92,7 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
_logger.LogInformation("Update data: {json}",
|
||||
JsonSerializer.Serialize(workerDataModel));
|
||||
ArgumentNullException.ThrowIfNull(workerDataModel);
|
||||
workerDataModel.Validate();
|
||||
workerDataModel.Validate(_localizer);
|
||||
_workerStorageContract.UpdElement(workerDataModel);
|
||||
}
|
||||
|
||||
@@ -100,7 +105,7 @@ internal class WorkerBusinessLogicContract(IWorkerStorageContract workerStorageC
|
||||
}
|
||||
if (!id.IsGuid())
|
||||
{
|
||||
throw new ValidationException("Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(_localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
}
|
||||
_workerStorageContract.DelElement(id);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface IPostBusinessLogicContract
|
||||
internal interface IPostBusinessLogicContract
|
||||
{
|
||||
List<PostDataModel> GetAllPosts();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface IProductBusinessLogicContract
|
||||
internal interface IProductBusinessLogicContract
|
||||
{
|
||||
List<ProductDataModel> GetAllProducts(bool onlyActive = true);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface IReportContract
|
||||
internal interface IReportContract
|
||||
{
|
||||
Task<List<ProductAndProductHistoryDataModel>> GetDataProductsByHistoryAsync(CancellationToken ct);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface ISalaryBusinessLogicContract
|
||||
internal interface ISalaryBusinessLogicContract
|
||||
{
|
||||
List<SalaryDataModel> GetAllSalariesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface ISaleBusinessLogicContract
|
||||
internal interface ISaleBusinessLogicContract
|
||||
{
|
||||
List<SaleDataModel> GetAllSalesByPeriod(DateTime fromDate, DateTime toDate);
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace North_Bridge_Contract.BusinessLogicsContracts;
|
||||
|
||||
public interface IWorkerBusinessLogicContract
|
||||
internal interface IWorkerBusinessLogicContract
|
||||
{
|
||||
List<WorkerDataModel> GetAllWorkers(bool onlyActive = true);
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@ using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.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;
|
||||
|
||||
@@ -32,24 +34,24 @@ public class PostDataModel(string postId, string postName, PostType postType, Po
|
||||
}
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (PostName.IsEmpty())
|
||||
throw new ValidationException("Field PostName is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostName"));
|
||||
|
||||
if (PostType == PostType.None)
|
||||
throw new ValidationException("Field PostType is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostType"));
|
||||
|
||||
if (ConfigurationModel is null)
|
||||
throw new ValidationException("Field ConfigurationModel is not initialized");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotInitialized"], "ConfigurationModel"));
|
||||
|
||||
if (ConfigurationModel!.Rate <= 0)
|
||||
throw new ValidationException("Field Rate is less or equal zero");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Rate"));
|
||||
}
|
||||
}
|
||||
@@ -1,48 +1,41 @@
|
||||
using North_Bridge_Contract.Enums;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Enums;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class ProductDataModel : IValidation
|
||||
internal class ProductDataModel(string id, string productName, ProductType productType, double price, bool isDeleted) : IValidation
|
||||
{
|
||||
public string Id { get; private set; }
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
public string ProductName { get; private set; }
|
||||
public string ProductName { get; private set; } = productName;
|
||||
|
||||
public ProductType ProductType { get; private set; }
|
||||
public ProductType ProductType { get; private set; } = productType;
|
||||
|
||||
public double Price { get; private set; }
|
||||
public double Price { get; private set; } = price;
|
||||
|
||||
public bool IsDeleted { get; private set; }
|
||||
|
||||
public ProductDataModel(string id, string productName, ProductType productType, double price, bool isDeleted)
|
||||
{
|
||||
Id = id;
|
||||
ProductName = productName;
|
||||
ProductType = productType;
|
||||
Price = price;
|
||||
IsDeleted = isDeleted;
|
||||
}
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
|
||||
public ProductDataModel(string id, string productName, ProductType productType, double price) : this(id, productName, productType, price, false) { }
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (ProductName.IsEmpty())
|
||||
throw new ValidationException("Field ProductName is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ProductName"));
|
||||
|
||||
if (ProductType == ProductType.None)
|
||||
throw new ValidationException("Field ProductType is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ProductType"));
|
||||
|
||||
if (Price <= 0)
|
||||
throw new ValidationException("Field Price is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
}
|
||||
}
|
||||
@@ -1,56 +1,49 @@
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class ProductForSaleDataModel : IValidation
|
||||
internal class ProductForSaleDataModel(string saleId, string productId, int count, double price) : IValidation
|
||||
{
|
||||
private readonly ProductDataModel _product;
|
||||
|
||||
public string SaleId { get; private set; }
|
||||
public string SaleId { get; private set; } = saleId;
|
||||
|
||||
public string ProductId { get; private set; }
|
||||
public string ProductId { get; private set; } = productId;
|
||||
|
||||
public int Count { get; private set; }
|
||||
public int Count { get; private set; } = count;
|
||||
|
||||
public double Price { get; private set; }
|
||||
public double Price { get; private set; } = price;
|
||||
|
||||
public string ProductName => _product?.ProductName ?? string.Empty;
|
||||
|
||||
public ProductForSaleDataModel(string saleId, string productId, int count, double price)
|
||||
{
|
||||
SaleId = saleId;
|
||||
ProductId = productId;
|
||||
Count = count;
|
||||
Price = price;
|
||||
}
|
||||
|
||||
public ProductForSaleDataModel(string saleId, string productId, int count, double price, ProductDataModel product) : this(saleId, productId, count, price)
|
||||
{
|
||||
_product = product;
|
||||
}
|
||||
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (SaleId.IsEmpty())
|
||||
throw new ValidationException("Field SaleId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "SaleId"));
|
||||
|
||||
if (!SaleId.IsGuid())
|
||||
throw new ValidationException("The value in the field SaleId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "SaleId"));
|
||||
|
||||
if (ProductId.IsEmpty())
|
||||
throw new ValidationException("Field ProductId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ProductId"));
|
||||
|
||||
if (!ProductId.IsGuid())
|
||||
throw new ValidationException("The value in the field ProductId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "ProductId"));
|
||||
|
||||
if (Count <= 0)
|
||||
throw new ValidationException("Field Count is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Count"));
|
||||
|
||||
if (Price <= 0)
|
||||
throw new ValidationException("Field Price is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Price"));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class ProductHistoryDataModel(string productId, double oldPrice) : IValidation
|
||||
internal class ProductHistoryDataModel(string productId, double oldPrice) : IValidation
|
||||
{
|
||||
private readonly ProductDataModel _product;
|
||||
|
||||
@@ -22,15 +24,15 @@ public class ProductHistoryDataModel(string productId, double oldPrice) : IValid
|
||||
_product = product;
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (ProductId.IsEmpty())
|
||||
throw new ValidationException("Field ProductId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "ProductId"));
|
||||
|
||||
if (!ProductId.IsGuid())
|
||||
throw new ValidationException("The value in the field ProductId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "ProductId"));
|
||||
|
||||
if (OldPrice <= 0)
|
||||
throw new ValidationException("Field OldPrice is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "OldPrice"));
|
||||
}
|
||||
}
|
||||
@@ -1,42 +1,37 @@
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class SalaryDataModel : IValidation
|
||||
internal class SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary) : IValidation
|
||||
{
|
||||
private readonly WorkerDataModel _worker;
|
||||
|
||||
public string WorkerId { get; private set; }
|
||||
public string WorkerId { get; private set; } = workerId;
|
||||
|
||||
public DateTime SalaryDate { get; private set; }
|
||||
public DateTime SalaryDate { get; private set; } = salaryDate.ToUniversalTime();
|
||||
|
||||
public double Salary { get; private set; }
|
||||
public double Salary { get; private set; } = workerSalary;
|
||||
|
||||
public string WorkerFIO => _worker?.FIO ?? string.Empty;
|
||||
|
||||
public SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary)
|
||||
{
|
||||
WorkerId = workerId;
|
||||
SalaryDate = salaryDate;
|
||||
Salary = workerSalary;
|
||||
}
|
||||
|
||||
public SalaryDataModel(string workerId, DateTime salaryDate, double workerSalary, WorkerDataModel worker) : this(workerId, salaryDate, workerSalary)
|
||||
{
|
||||
_worker = worker;
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "WorkerId"));
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
|
||||
if (Salary <= 0)
|
||||
throw new ValidationException("Field Salary is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Salary"));
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class SaleDataModel : IValidation
|
||||
internal class SaleDataModel : IValidation
|
||||
{
|
||||
private readonly WorkerDataModel _worker;
|
||||
|
||||
@@ -12,7 +14,7 @@ public class SaleDataModel : IValidation
|
||||
|
||||
public string WorkerId { get; private set; }
|
||||
|
||||
public DateTime SaleDate { get; private set; } = DateTime.Now;
|
||||
public DateTime SaleDate { get; private set; } = DateTime.UtcNow;
|
||||
|
||||
public double Sum { get; private set; }
|
||||
|
||||
@@ -41,24 +43,29 @@ public class SaleDataModel : IValidation
|
||||
|
||||
public SaleDataModel(string id, string workerId, List<ProductForSaleDataModel> products) : this(id, workerId, false, products) { }
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (WorkerId.IsEmpty())
|
||||
throw new ValidationException("Field WorkerId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "WorkerId"));
|
||||
|
||||
if (!WorkerId.IsGuid())
|
||||
throw new ValidationException("The value in the field WorkerId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "WorkerId"));
|
||||
|
||||
if (Sum <= 0)
|
||||
throw new ValidationException("Field Sum is less than or equal to 0");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageLessOrEqualZero"], "Sum"));
|
||||
|
||||
if ((Products?.Count ?? 0) == 0)
|
||||
throw new ValidationException("The sale must include products");
|
||||
if (Products is null)
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotInitialized"], "Products"));
|
||||
|
||||
if (Products.Count == 0)
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageNoProductInSale"]);
|
||||
|
||||
Products.ForEach(x => x.Validate(localizer));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,31 @@
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Infrastructure;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using System.Text.RegularExpressions;
|
||||
namespace North_Bridge_Contract.DataModels;
|
||||
|
||||
public class WorkerDataModel : IValidation
|
||||
internal class WorkerDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted) : IValidation
|
||||
{
|
||||
public readonly PostDataModel _post;
|
||||
|
||||
public string Id { get; private set; }
|
||||
public string Id { get; private set; } = id;
|
||||
|
||||
public string FIO { get; private set; }
|
||||
public string FIO { get; private set; } = fio;
|
||||
|
||||
public string Email { get; private set; }
|
||||
public string Email { get; private set; } = email;
|
||||
|
||||
public string PostId { get; private set; }
|
||||
public string PostId { get; private set; } = postId;
|
||||
|
||||
public DateTime BirthDate { get; private set; }
|
||||
public DateTime BirthDate { get; private set; } = birthDate.ToUniversalTime();
|
||||
|
||||
public DateTime EmploymentDate { get; private set; }
|
||||
public DateTime EmploymentDate { get; private set; } = employmentDate.ToUniversalTime();
|
||||
|
||||
public bool IsDeleted { get; private set; }
|
||||
public bool IsDeleted { get; private set; } = isDeleted;
|
||||
|
||||
public string PostName => _post?.PostName ?? string.Empty;
|
||||
|
||||
public WorkerDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted)
|
||||
{
|
||||
Id = id;
|
||||
FIO = fio;
|
||||
Email = email;
|
||||
PostId = postId;
|
||||
BirthDate = birthDate;
|
||||
EmploymentDate = employmentDate;
|
||||
IsDeleted = isDeleted;
|
||||
}
|
||||
|
||||
public WorkerDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate, bool isDeleted, PostDataModel post) :
|
||||
this(id, fio, email, postId, birthDate, employmentDate, isDeleted)
|
||||
{
|
||||
@@ -43,36 +34,38 @@ public class WorkerDataModel : IValidation
|
||||
|
||||
public WorkerDataModel(string id, string fio, string email, string postId, DateTime birthDate, DateTime employmentDate) : this(id, fio, email, postId, birthDate, employmentDate, false) { }
|
||||
|
||||
public void Validate()
|
||||
public void Validate(IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
if (Id.IsEmpty())
|
||||
throw new ValidationException("Field Id is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Id"));
|
||||
|
||||
if (!Id.IsGuid())
|
||||
throw new ValidationException("The value in the field Id is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "Id"));
|
||||
|
||||
if (FIO.IsEmpty())
|
||||
throw new ValidationException("Field FIO is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "FIO"));
|
||||
|
||||
if (Email.IsEmpty())
|
||||
throw new ValidationException("Field Email is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "Email"));
|
||||
|
||||
if (!Regex.IsMatch(Email, @"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$"))
|
||||
throw new ValidationException("Field Email is not a valid email address");
|
||||
throw new ValidationException(localizer["ValidationExceptionMessageIncorrectEmail"]);
|
||||
|
||||
if (PostId.IsEmpty())
|
||||
throw new ValidationException("Field PostId is empty");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmptyField"], "PostId"));
|
||||
|
||||
if (!PostId.IsGuid())
|
||||
throw new ValidationException("The value in the field PostId is not a unique identifier");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageNotAId"], "PostId"));
|
||||
|
||||
if (BirthDate.Date > DateTime.Now.AddYears(-18).Date)
|
||||
throw new ValidationException($"Only adults can be hired (BirthDate = {BirthDate.ToShortDateString()})");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageMinorsBirthDate"], BirthDate.ToShortDateString()));
|
||||
|
||||
if (EmploymentDate.Date < BirthDate.Date)
|
||||
throw new ValidationException("The date of employment cannot be less than the date of birth");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageEmploymentDateAndBirthDate"],
|
||||
EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()));
|
||||
|
||||
if ((EmploymentDate - BirthDate).TotalDays / 365 < 18)
|
||||
throw new ValidationException($"Only adults can be hired (EmploymentDate - {EmploymentDate.ToShortDateString()}, BirthDate - {BirthDate.ToShortDateString()})");
|
||||
throw new ValidationException(string.Format(localizer["ValidationExceptionMessageMinorsEmploymentDate"],
|
||||
EmploymentDate.ToShortDateString(), BirthDate.ToShortDateString()));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
public class ElementDeletedException : Exception
|
||||
{
|
||||
public ElementDeletedException(string id) : base($"Cannot modify a deleted item(id: { id})") { }
|
||||
}
|
||||
internal class ElementDeletedException(string id, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementDeletedExceptionMessage"], id))
|
||||
{ }
|
||||
@@ -1,15 +1,13 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.Extentions;
|
||||
|
||||
public class ElementExistsException : Exception
|
||||
internal class ElementExistsException(string paramName, string paramValue, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementExistsExceptionMessage"], paramValue, paramName))
|
||||
{
|
||||
public string ParamName { get; private set; }
|
||||
|
||||
public string ParamValue { get; private set; }
|
||||
|
||||
public ElementExistsException(string paramName, string paramValue) : base($"There is already an element with value{paramValue} of parameter { paramName}")
|
||||
{
|
||||
ParamName = paramName;
|
||||
ParamValue = paramValue;
|
||||
}
|
||||
public string ParamName { get; private set; } = paramName;
|
||||
|
||||
public string ParamValue { get; private set; } = paramValue;
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
public class ElementNotFoundException : Exception
|
||||
internal class ElementNotFoundException(string value, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["ElementNotFoundExceptionMessage"], value))
|
||||
{
|
||||
public string Value { get; private set; }
|
||||
|
||||
public ElementNotFoundException(string value) : base($"Element not found at value = { value}")
|
||||
{
|
||||
Value = value;
|
||||
}
|
||||
public string Value { get; private set; } = value;
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
public class IncorrectDatesException : Exception
|
||||
{
|
||||
public IncorrectDatesException(DateTime start, DateTime end) : base($"The end date must be later than the start date..StartDate: { start: dd.MM.YYYY}. EndDate: {end:dd.MM.YYYY}") { }
|
||||
}
|
||||
internal class IncorrectDatesException(DateTime start, DateTime end, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["IncorrectDatesExceptionMessage"], start.ToShortDateString(), end.ToShortDateString()))
|
||||
{ }
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
public class NullListException : Exception
|
||||
{
|
||||
public NullListException() : base("The returned list is null") { }
|
||||
|
||||
public NullListException(string message) : base(message)
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
public class StorageException : Exception
|
||||
{
|
||||
public StorageException(Exception ex) : base($"Error while working in storage: {ex.Message}", ex) { }
|
||||
}
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
internal class StorageException(Exception ex, IStringLocalizer<Messages> localizer) :
|
||||
Exception(string.Format(localizer["StorageExceptionMessage"], ex.Message), ex)
|
||||
{ }
|
||||
@@ -1,10 +1,6 @@
|
||||
|
||||
namespace North_Bridge_Contract.Exceptions;
|
||||
|
||||
public class ValidationException : Exception
|
||||
public class ValidationException(string message) : Exception(message)
|
||||
{
|
||||
public ValidationException(string message) : base(message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.Resources;
|
||||
|
||||
namespace North_Bridge_Contract.Infrastructure;
|
||||
|
||||
public interface IValidation
|
||||
internal interface IValidation
|
||||
{
|
||||
void Validate();
|
||||
void Validate(IStringLocalizer<Messages> localizer);
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
namespace North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using System.Globalization;
|
||||
|
||||
namespace North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
|
||||
public class PostConfiguration
|
||||
{
|
||||
public virtual string Type => nameof(PostConfiguration);
|
||||
|
||||
public double Rate { get; set; }
|
||||
|
||||
public string CultureName { get; set; } = CultureInfo.CurrentCulture.Name;
|
||||
}
|
||||
@@ -1,29 +1,51 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>disable</Nullable>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<LangVersion>preview</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.AspNetCore" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.3.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Messages.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<InternalsVisibleTo Include="North_Bridge_BusinessLogics" />
|
||||
<InternalsVisibleTo Include="North_Bridge_DataBase" />
|
||||
<InternalsVisibleTo Include="North_Bridge_Tests" />
|
||||
<InternalsVisibleTo Include="North_Bridge_WebApi" />
|
||||
<InternalsVisibleTo Include="DynamicProxyGenAssembly2" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
414
North_Bridge/North_Bridge_Contract/Resources/Messages.Designer.cs
generated
Normal file
414
North_Bridge/North_Bridge_Contract/Resources/Messages.Designer.cs
generated
Normal file
@@ -0,0 +1,414 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace North_Bridge_Contract.Resources {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Messages {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Messages() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("North_Bridge_Contract.Resources.Messages", typeof(Messages).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Элемент по данным: {0} был удален.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageElementDeletedException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageElementDeletedException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Не найден элемент по данным: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageElementNotFoundException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageElementNotFoundException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Данные пусты.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageEmptyDate {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageEmptyDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Неправильные даты: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageIncorrectDatesException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageIncorrectDatesException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Ошибка при обработке данных: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageInvalidOperationException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageInvalidOperationException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Ошибка при работе с хранилищем данных: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageStorageException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageStorageException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Переданы неверные данные: {0}.
|
||||
/// </summary>
|
||||
internal static string AdapterMessageValidationException {
|
||||
get {
|
||||
return ResourceManager.GetString("AdapterMessageValidationException", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата изменения.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionDate {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Старая цена.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionOldPrice {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionOldPrice", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Товар.
|
||||
/// </summary>
|
||||
internal static string DocumentDocCaptionProduct {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocCaptionProduct", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на История продуктов.
|
||||
/// </summary>
|
||||
internal static string DocumentDocHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Сформировано на дату {0}.
|
||||
/// </summary>
|
||||
internal static string DocumentDocSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentDocSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Кол-во.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionCount {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionCount", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionDate {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Товар.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionProduct {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionProduct", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Сумма.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionSum {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionSum", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Всего.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelCaptionTotal {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelCaptionTotal", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Продажи за период.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на c {0} по {1}.
|
||||
/// </summary>
|
||||
internal static string DocumentExcelSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentExcelSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Начисления.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfDiagramCaption {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfDiagramCaption", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Зарплатная ведомость.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на за период с {0} по {1}.
|
||||
/// </summary>
|
||||
internal static string DocumentPdfSubHeader {
|
||||
get {
|
||||
return ResourceManager.GetString("DocumentPdfSubHeader", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Нельзя изменить удаленный элемент (идентификатор: {0}).
|
||||
/// </summary>
|
||||
internal static string ElementDeletedExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementDeletedExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Уже существует элемент со значением {0} параметра {1}.
|
||||
/// </summary>
|
||||
internal static string ElementExistsExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementExistsExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Элемент не найден по значению = {0}.
|
||||
/// </summary>
|
||||
internal static string ElementNotFoundExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("ElementNotFoundExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата окончания должна быть позже даты начала. Дата начала: {0}. Дата окончания: {1}.
|
||||
/// </summary>
|
||||
internal static string IncorrectDatesExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("IncorrectDatesExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Недостаточно данных для обработки: {0}.
|
||||
/// </summary>
|
||||
internal static string NotEnoughDataToProcessExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("NotEnoughDataToProcessExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Не найдены данные.
|
||||
/// </summary>
|
||||
internal static string NotFoundDataMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("NotFoundDataMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Ошибка при работе в хранилище: {0}.
|
||||
/// </summary>
|
||||
internal static string StorageExceptionMessage {
|
||||
get {
|
||||
return ResourceManager.GetString("StorageExceptionMessage", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Дата трудоустройства не может быть раньше даты рождения ({0}, {1}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageEmploymentDateAndBirthDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageEmploymentDateAndBirthDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} пусто.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageEmptyField {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageEmptyField", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле Электронная почта не является электронной почтой.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectEmail {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectEmail", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле Телефонный номер не является телефонным номером.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageIncorrectPhoneNumber {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageIncorrectPhoneNumber", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0} меньше или равно 0.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageLessOrEqualZero {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageLessOrEqualZero", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Несовершеннолетние не могут быть приняты на работу (Дата рождения: {0}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageMinorsBirthDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageMinorsBirthDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Несовершеннолетние не могут быть приняты на работу (Дата трудоустройства: {0}, Дата рождения: {1}).
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageMinorsEmploymentDate {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageMinorsEmploymentDate", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на В продаже должен быть хотя бы один товар.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNoProductInSale {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNoProductInSale", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле {0}, не является типом уникального идентификатора.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNotAId {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNotAId", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ищет локализованную строку, похожую на Значение в поле , не проинициализировано.
|
||||
/// </summary>
|
||||
internal static string ValidationExceptionMessageNotInitialized {
|
||||
get {
|
||||
return ResourceManager.GetString("ValidationExceptionMessageNotInitialized", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
237
North_Bridge/North_Bridge_Contract/Resources/Messages.de-DE.resx
Normal file
237
North_Bridge/North_Bridge_Contract/Resources/Messages.de-DE.resx
Normal file
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>Element nach Daten: {0} wurde gelöscht</value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Element mit Daten: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>Die Daten sind leer</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Falsche Datumsangaben: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Fehler bei der Datenverarbeitung: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Fehler beim Arbeiten mit dem Datenspeicher: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Falsche Daten übergeben: Wert im Feld: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionDate" xml:space="preserve">
|
||||
<value>Änderungsdatum</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Alter Preis</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionProduct" xml:space="preserve">
|
||||
<value>Produkt-Name</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>Produkt-Geschichte</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Erstellt am Datum {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Anzahl</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Datum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionProduct" xml:space="preserve">
|
||||
<value>Ware</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Summe</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Insgesamt</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Umsatz pro Zeitraum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>c {0} nach {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Anrechnungen</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Gehaltsliste</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value>für den Zeitraum {0} bis {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>Das gelöschte Element kann nicht geändert werden (ID: {0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>Fehler beim Zugriff auf den Datenspeicher {0} des Parameters {1} vorhanden</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>Element wurde nicht durch Wert = {0} gefunden</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>Das Enddatum muss später als das Startdatum sein. Startdatum: {0}. Enddatum: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Zu verarbeitende Daten sind nicht ausreichend: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>Keine Daten gefunden</value>
|
||||
</data>
|
||||
<data name="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>Fehler beim Ausführen im Speicher: {0}</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>Das Beschäftigungsdatum darf nicht vor dem Geburtsdatum liegen ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>Der Wert im Feld "{0}" ist leer</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>Der Wert im Feld E-Mail ist keine E-Mail</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" xml:space="preserve">
|
||||
<value>Der Wert im Feld Telefonnummer ist keine Telefonnummer</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>Der Wert im Feld {0} ist kleiner oder gleich 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Minderjährige können nicht eingestellt werden (Geburtsdatum: {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Minderjährige können nicht eingestellt werden (Beschäftigungsdatum: {0}, Geburtsdatum: {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoProductInSale" xml:space="preserve">
|
||||
<value>Es muss mindestens ein Produkt zum Verkauf stehen</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>Der Wert im Feld "{0}" ist kein eindeutiger Bezeichnertyp</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>Wert im Feld , nicht initialisiert</value>
|
||||
</data>
|
||||
</root>
|
||||
237
North_Bridge/North_Bridge_Contract/Resources/Messages.en-US.resx
Normal file
237
North_Bridge/North_Bridge_Contract/Resources/Messages.en-US.resx
Normal file
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>The item according to the data: {0} has been deleted</value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Not found element by data: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>The data is empty</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Incorrect dates: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Error during data processing: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Error when working with the data warehouse: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Incorrect data transmitted: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionDate" xml:space="preserve">
|
||||
<value>Date of change</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Old price</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionProduct" xml:space="preserve">
|
||||
<value>Product Name</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>Product History</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Generated on date {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Quantity</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Date</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionProduct" xml:space="preserve">
|
||||
<value>Product</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Sum</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Total</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Sales for the period</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>from {0} to {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Accruals</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Salary statement</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value>for the period from {0} to {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>A deleted item cannot be changed (id: {0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>There is already an element with value {0} of the parameter {1}</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>The element was not found by value = {0}</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>The end date must be later than the start date. Start date: {0}. End date: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Insufficient data to process: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>No data found</value>
|
||||
</data>
|
||||
<data name="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>Error when working in the storage: {0}</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>The date of employment cannot be earlier than the date of birth ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>The value in the {0} field is empty</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>The value in the Email field is not an email.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" xml:space="preserve">
|
||||
<value>The value in the Phone Number field is not a phone number.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>The value in the {0} field is less than or equal to 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Minors cannot be employed (Date of birth: {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Minors cannot be employed (Date of employment: {0}, Date of birth: {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoProductInSale" xml:space="preserve">
|
||||
<value>There must be at least one product on sale.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>The value in the {0} field is not a type of unique identifier.</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>Value in the field , not initialized</value>
|
||||
</data>
|
||||
</root>
|
||||
237
North_Bridge/North_Bridge_Contract/Resources/Messages.resx
Normal file
237
North_Bridge/North_Bridge_Contract/Resources/Messages.resx
Normal file
@@ -0,0 +1,237 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<data name="AdapterMessageElementDeletedException" xml:space="preserve">
|
||||
<value>Элемент по данным: {0} был удален</value>
|
||||
</data>
|
||||
<data name="AdapterMessageElementNotFoundException" xml:space="preserve">
|
||||
<value>Не найден элемент по данным: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageEmptyDate" xml:space="preserve">
|
||||
<value>Данные пусты</value>
|
||||
</data>
|
||||
<data name="AdapterMessageIncorrectDatesException" xml:space="preserve">
|
||||
<value>Неправильные даты: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageInvalidOperationException" xml:space="preserve">
|
||||
<value>Ошибка при обработке данных: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageStorageException" xml:space="preserve">
|
||||
<value>Ошибка при работе с хранилищем данных: {0}</value>
|
||||
</data>
|
||||
<data name="AdapterMessageValidationException" xml:space="preserve">
|
||||
<value>Переданы неверные данные: {0}</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionDate" xml:space="preserve">
|
||||
<value>Дата изменения</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionOldPrice" xml:space="preserve">
|
||||
<value>Старая цена</value>
|
||||
</data>
|
||||
<data name="DocumentDocCaptionProduct" xml:space="preserve">
|
||||
<value>Товар</value>
|
||||
</data>
|
||||
<data name="DocumentDocHeader" xml:space="preserve">
|
||||
<value>История продуктов</value>
|
||||
</data>
|
||||
<data name="DocumentDocSubHeader" xml:space="preserve">
|
||||
<value>Сформировано на дату {0}</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionCount" xml:space="preserve">
|
||||
<value>Кол-во</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionDate" xml:space="preserve">
|
||||
<value>Дата</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionProduct" xml:space="preserve">
|
||||
<value>Товар</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionSum" xml:space="preserve">
|
||||
<value>Сумма</value>
|
||||
</data>
|
||||
<data name="DocumentExcelCaptionTotal" xml:space="preserve">
|
||||
<value>Всего</value>
|
||||
</data>
|
||||
<data name="DocumentExcelHeader" xml:space="preserve">
|
||||
<value>Продажи за период</value>
|
||||
</data>
|
||||
<data name="DocumentExcelSubHeader" xml:space="preserve">
|
||||
<value>c {0} по {1}</value>
|
||||
</data>
|
||||
<data name="DocumentPdfDiagramCaption" xml:space="preserve">
|
||||
<value>Начисления</value>
|
||||
</data>
|
||||
<data name="DocumentPdfHeader" xml:space="preserve">
|
||||
<value>Зарплатная ведомость</value>
|
||||
</data>
|
||||
<data name="DocumentPdfSubHeader" xml:space="preserve">
|
||||
<value>за период с {0} по {1}</value>
|
||||
</data>
|
||||
<data name="ElementDeletedExceptionMessage" xml:space="preserve">
|
||||
<value>Нельзя изменить удаленный элемент (идентификатор: {0})</value>
|
||||
</data>
|
||||
<data name="ElementExistsExceptionMessage" xml:space="preserve">
|
||||
<value>Уже существует элемент со значением {0} параметра {1}</value>
|
||||
</data>
|
||||
<data name="ElementNotFoundExceptionMessage" xml:space="preserve">
|
||||
<value>Элемент не найден по значению = {0}</value>
|
||||
</data>
|
||||
<data name="IncorrectDatesExceptionMessage" xml:space="preserve">
|
||||
<value>Дата окончания должна быть позже даты начала. Дата начала: {0}. Дата окончания: {1}</value>
|
||||
</data>
|
||||
<data name="NotEnoughDataToProcessExceptionMessage" xml:space="preserve">
|
||||
<value>Недостаточно данных для обработки: {0}</value>
|
||||
</data>
|
||||
<data name="NotFoundDataMessage" xml:space="preserve">
|
||||
<value>Не найдены данные</value>
|
||||
</data>
|
||||
<data name="StorageExceptionMessage" xml:space="preserve">
|
||||
<value>Ошибка при работе в хранилище: {0}</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmploymentDateAndBirthDate" xml:space="preserve">
|
||||
<value>Дата трудоустройства не может быть раньше даты рождения ({0}, {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageEmptyField" xml:space="preserve">
|
||||
<value>Значение в поле {0} пусто</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectEmail" xml:space="preserve">
|
||||
<value>Значение в поле Электронная почта не является электронной почтой</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageIncorrectPhoneNumber" xml:space="preserve">
|
||||
<value>Значение в поле Телефонный номер не является телефонным номером</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageLessOrEqualZero" xml:space="preserve">
|
||||
<value>Значение в поле {0} меньше или равно 0</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsBirthDate" xml:space="preserve">
|
||||
<value>Несовершеннолетние не могут быть приняты на работу (Дата рождения: {0})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageMinorsEmploymentDate" xml:space="preserve">
|
||||
<value>Несовершеннолетние не могут быть приняты на работу (Дата трудоустройства: {0}, Дата рождения: {1})</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNoProductInSale" xml:space="preserve">
|
||||
<value>В продаже должен быть хотя бы один товар</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotAId" xml:space="preserve">
|
||||
<value>Значение в поле {0}, не является типом уникального идентификатора</value>
|
||||
</data>
|
||||
<data name="ValidationExceptionMessageNotInitialized" xml:space="preserve">
|
||||
<value>Значение в поле , не проинициализировано</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
public interface IPostStorageContract
|
||||
internal interface IPostStorageContract
|
||||
{
|
||||
List<PostDataModel> GetList();
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
public interface IProductStorageContract
|
||||
internal interface IProductStorageContract
|
||||
{
|
||||
List<ProductDataModel> GetList(bool onlyActive = true);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
public interface ISalaryStorageContract
|
||||
internal interface ISalaryStorageContract
|
||||
{
|
||||
List<SalaryDataModel> GetList(DateTime startDate, DateTime endDate, string workerId = null);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
public interface ISaleStorageContract
|
||||
internal interface ISaleStorageContract
|
||||
{
|
||||
List<SaleDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string workerId = null, string productId = null);
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace North_Bridge_Contract.StoragesContracts;
|
||||
|
||||
public interface IWorkerStorageContract
|
||||
internal interface IWorkerStorageContract
|
||||
{
|
||||
List<WorkerDataModel> GetList(bool onlyActive = true, string? postId = null, DateTime? fromBirthDate = null, DateTime? toBirthDate = null, DateTime? fromEmploymentDate = null, DateTime? toEmploymentDate = null);
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using Npgsql;
|
||||
@@ -15,7 +17,9 @@ namespace North_Bridge_DataBase.Implementations
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public PostStorageContract(North_Bridge_DbContext dbContext)
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
public PostStorageContract(North_Bridge_DbContext dbContext, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
@@ -31,6 +35,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
.ForMember(x => x.Configuration, x => x.MapFrom(src => src.ConfigurationModel));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public List<PostDataModel> GetList()
|
||||
@@ -42,7 +47,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +62,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +77,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +92,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -103,18 +108,18 @@ namespace North_Bridge_DataBase.Implementations
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostName",
|
||||
postDataModel.PostName);
|
||||
postDataModel.PostName, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Posts_PostId_IsActual" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostId", postDataModel.Id);
|
||||
throw new ElementExistsException("PostId", postDataModel.Id, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,11 +131,11 @@ namespace North_Bridge_DataBase.Implementations
|
||||
try
|
||||
{
|
||||
var element = GetPostById(postDataModel.Id) ?? throw new
|
||||
ElementNotFoundException(postDataModel.Id);
|
||||
ElementNotFoundException(postDataModel.Id, _localizer);
|
||||
if (!element.IsActual)
|
||||
{
|
||||
throw new
|
||||
ElementDeletedException(postDataModel.Id);
|
||||
ElementDeletedException(postDataModel.Id, _localizer);
|
||||
}
|
||||
element.IsActual = false;
|
||||
_dbContext.SaveChanges();
|
||||
@@ -150,7 +155,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("PostName",
|
||||
postDataModel.PostName);
|
||||
postDataModel.PostName, _localizer);
|
||||
}
|
||||
catch (Exception ex) when (ex is ElementDeletedException || ex is
|
||||
ElementNotFoundException)
|
||||
@@ -161,7 +166,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,10 +175,10 @@ namespace North_Bridge_DataBase.Implementations
|
||||
try
|
||||
{
|
||||
var element = GetPostById(id) ?? throw new
|
||||
ElementNotFoundException(id);
|
||||
ElementNotFoundException(id, _localizer);
|
||||
if (!element.IsActual)
|
||||
{
|
||||
throw new ElementDeletedException(id);
|
||||
throw new ElementDeletedException(id, _localizer);
|
||||
}
|
||||
element.IsActual = false;
|
||||
_dbContext.SaveChanges();
|
||||
@@ -190,7 +195,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
try
|
||||
{
|
||||
var element = GetPostById(id) ?? throw new
|
||||
ElementNotFoundException(id);
|
||||
ElementNotFoundException(id, _localizer);
|
||||
element.IsActual = true;
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using Npgsql;
|
||||
@@ -15,7 +17,9 @@ namespace North_Bridge_DataBase.Implementations
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public ProductStorageContract(North_Bridge_DbContext dbContext)
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
public ProductStorageContract(North_Bridge_DbContext dbContext, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
@@ -27,6 +31,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
cfg.CreateMap<ProductHistory, ProductHistoryDataModel>();
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public List<ProductDataModel> GetList(bool onlyActive = true)
|
||||
@@ -43,7 +48,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
public List<ProductHistoryDataModel> GetHistoryByProductId(string productId)
|
||||
@@ -57,7 +62,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,7 +75,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +88,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -98,7 +103,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,19 +118,24 @@ namespace North_Bridge_DataBase.Implementations
|
||||
"ThrowIdentityConflict")
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", productDataModel.Id);
|
||||
throw new ElementExistsException("Id", productDataModel.Id, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is
|
||||
PostgresException { ConstraintName: "IX_Products_ProductName_IsDeleted" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("ProductName",
|
||||
productDataModel.ProductName);
|
||||
productDataModel.ProductName, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is PostgresException { ConstraintName: "PK_Products" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", productDataModel.Id, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -137,7 +147,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
try
|
||||
{
|
||||
var element = GetProductById(productDataModel.Id) ??
|
||||
throw new ElementNotFoundException(productDataModel.Id);
|
||||
throw new ElementNotFoundException(productDataModel.Id, _localizer);
|
||||
if (element.Price != productDataModel.Price)
|
||||
{
|
||||
_dbContext.ProductHistories.Add(new
|
||||
@@ -161,7 +171,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("ProductName",
|
||||
productDataModel.ProductName);
|
||||
productDataModel.ProductName, _localizer);
|
||||
}
|
||||
catch (Exception ex) when (ex is ElementDeletedException || ex is
|
||||
ElementNotFoundException)
|
||||
@@ -172,7 +182,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,7 +191,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
try
|
||||
{
|
||||
var element = GetProductById(id) ?? throw new
|
||||
ElementNotFoundException(id);
|
||||
ElementNotFoundException(id, _localizer);
|
||||
element.IsDeleted = true;
|
||||
_dbContext.SaveChanges();
|
||||
}
|
||||
@@ -193,7 +203,7 @@ namespace North_Bridge_DataBase.Implementations
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
|
||||
@@ -13,7 +15,9 @@ internal class SalaryStorageContract : ISalaryStorageContract
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public SalaryStorageContract(North_Bridge_DbContext dbContext)
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
public SalaryStorageContract(North_Bridge_DbContext dbContext, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
@@ -25,6 +29,7 @@ internal class SalaryStorageContract : ISalaryStorageContract
|
||||
opt.MapFrom(src => src.Salary));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public List<SalaryDataModel> GetList(DateTime startDate, DateTime endDate, string? workerId = null)
|
||||
@@ -42,7 +47,7 @@ internal class SalaryStorageContract : ISalaryStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +60,7 @@ internal class SalaryStorageContract : ISalaryStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,7 +74,7 @@ internal class SalaryStorageContract : ISalaryStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
|
||||
@@ -13,7 +15,9 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public SaleStorageContract(North_Bridge_DbContext dbContext)
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
public SaleStorageContract(North_Bridge_DbContext dbContext, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
@@ -39,6 +43,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
.ForMember(x => x.ProductsForSale, x => x.MapFrom(src => src.Products));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public List<SaleDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string? workerId = null, string? productId = null)
|
||||
@@ -68,7 +73,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +93,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,7 +106,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +120,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,10 +129,10 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
try
|
||||
{
|
||||
var element = GetSaleById(id) ?? throw new
|
||||
ElementNotFoundException(id);
|
||||
ElementNotFoundException(id, _localizer);
|
||||
if (element.IsCancel)
|
||||
{
|
||||
throw new ElementDeletedException(id);
|
||||
throw new ElementDeletedException(id, _localizer);
|
||||
}
|
||||
element.IsCancel = true;
|
||||
_dbContext.SaveChanges();
|
||||
@@ -141,7 +146,7 @@ internal class SaleStorageContract : ISaleStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,14 @@
|
||||
|
||||
using AutoMapper;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using Npgsql;
|
||||
|
||||
namespace North_Bridge_DataBase.Implementations;
|
||||
|
||||
@@ -15,7 +18,9 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public WorkerStorageContract(North_Bridge_DbContext dbContext)
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
public WorkerStorageContract(North_Bridge_DbContext dbContext, IStringLocalizer<Messages> localizer)
|
||||
{
|
||||
_dbContext = dbContext;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
@@ -26,6 +31,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
cfg.CreateMap<WorkerDataModel, Worker>();
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public List<WorkerDataModel> GetList(bool onlyActive = true, string? postId = null, DateTime? fromBirthDate = null, DateTime? toBirthDate = null, DateTime? fromEmploymentDate = null, DateTime? toEmploymentDate = null)
|
||||
@@ -54,7 +60,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +73,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +88,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +102,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,12 +117,17 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
"ThrowIdentityConflict")
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", workerDataModel.Id);
|
||||
throw new ElementExistsException("Id", workerDataModel.Id, _localizer);
|
||||
}
|
||||
catch (DbUpdateException ex) when (ex.InnerException is PostgresException { ConstraintName: "PK_Workers" })
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new ElementExistsException("Id", workerDataModel.Id, _localizer);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,7 +136,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
try
|
||||
{
|
||||
var element = GetWorkerById(workerDataModel.Id) ?? throw new
|
||||
ElementNotFoundException(workerDataModel.Id);
|
||||
ElementNotFoundException(workerDataModel.Id, _localizer);
|
||||
_dbContext.Workers.Update(_mapper.Map(workerDataModel,
|
||||
element));
|
||||
_dbContext.SaveChanges();
|
||||
@@ -138,7 +149,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +158,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
try
|
||||
{
|
||||
var element = GetWorkerById(id) ?? throw new
|
||||
ElementNotFoundException(id);
|
||||
ElementNotFoundException(id, _localizer);
|
||||
element.IsDeleted = true;
|
||||
element.DateOfDelete = DateTime.UtcNow;
|
||||
_dbContext.SaveChanges();
|
||||
@@ -160,7 +171,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,7 +188,7 @@ internal class WorkerStorageContract : IWorkerStorageContract
|
||||
catch (Exception ex)
|
||||
{
|
||||
_dbContext.ChangeTracker.Clear();
|
||||
throw new StorageException(ex);
|
||||
throw new StorageException(ex, _localizer);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,8 +14,6 @@ public class North_Bridge_DbContext : DbContext
|
||||
public North_Bridge_DbContext(IConfigurationDatabase? configurationDatabase)
|
||||
{
|
||||
_configurationDatabase = configurationDatabase;
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
|
||||
}
|
||||
|
||||
public North_Bridge_DbContext() : this(new DefaultConfigurationDatabase())
|
||||
|
||||
@@ -7,6 +7,7 @@ using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.BusinessLogicsContractsTests;
|
||||
|
||||
@@ -21,7 +22,7 @@ internal class PostBusinessLogicContractTests
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_postStorageContract = new Mock<IPostStorageContract>();
|
||||
_postBusinessLogicContract = new PostBusinessLogicContract(_postStorageContract.Object, new Mock<ILogger>().Object);
|
||||
_postBusinessLogicContract = new PostBusinessLogicContract(_postStorageContract.Object, new Mock<ILogger>().Object, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -71,23 +72,12 @@ internal class PostBusinessLogicContractTests
|
||||
});
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllPosts_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.GetAllPosts(),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_postStorageContract.Verify(x => x.GetList(),
|
||||
Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllPosts_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.GetList()).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetList()).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.GetAllPosts(),
|
||||
@@ -155,23 +145,12 @@ internal class PostBusinessLogicContractTests
|
||||
x.GetPostWithHistory(It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllDataOfPost_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.GetAllDataOfPost(Guid.NewGuid().ToString()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_postStorageContract.Verify(x =>
|
||||
x.GetPostWithHistory(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllDataOfPost_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.GetPostWithHistory(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetPostWithHistory(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.GetAllDataOfPost(Guid.NewGuid().ToString()),
|
||||
@@ -260,9 +239,9 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
_postStorageContract.Setup(x =>
|
||||
x.GetElementByName(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementByName(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.GetPostByData(Guid.NewGuid().ToString()),
|
||||
@@ -304,7 +283,7 @@ internal class PostBusinessLogicContractTests
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<PostDataModel>())).Throws(new
|
||||
ElementExistsException("Data", "Data"));
|
||||
ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.InsertPost(new(Guid.NewGuid().ToString(), "name",
|
||||
@@ -340,7 +319,7 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<PostDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.AddElement(It.IsAny<PostDataModel>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.InsertPost(new(Guid.NewGuid().ToString(), "name",
|
||||
@@ -379,7 +358,7 @@ internal class PostBusinessLogicContractTests
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<PostDataModel>())).Throws(new
|
||||
ElementNotFoundException(""));
|
||||
ElementNotFoundException("", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.UpdatePost(new(Guid.NewGuid().ToString(), "name",
|
||||
@@ -394,7 +373,7 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<PostDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
x.UpdElement(It.IsAny<PostDataModel>())).Throws(new ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.UpdatePost(new(Guid.NewGuid().ToString(), "anme",
|
||||
@@ -430,7 +409,7 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<PostDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.UpdElement(It.IsAny<PostDataModel>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.UpdatePost(new(Guid.NewGuid().ToString(), "name",
|
||||
@@ -462,7 +441,7 @@ internal class PostBusinessLogicContractTests
|
||||
//Arrange
|
||||
var id = Guid.NewGuid().ToString();
|
||||
_postStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id));
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id, StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.DeletePost(Guid.NewGuid().ToString()),
|
||||
@@ -499,7 +478,7 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.DeletePost(Guid.NewGuid().ToString()),
|
||||
@@ -530,7 +509,7 @@ internal class PostBusinessLogicContractTests
|
||||
//Arrange
|
||||
var id = Guid.NewGuid().ToString();
|
||||
_postStorageContract.Setup(x =>
|
||||
x.ResElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id));
|
||||
x.ResElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id, StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.RestorePost(Guid.NewGuid().ToString()),
|
||||
@@ -567,7 +546,7 @@ internal class PostBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_postStorageContract.Setup(x =>
|
||||
x.ResElement(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.ResElement(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_postBusinessLogicContract.RestorePost(Guid.NewGuid().ToString()),
|
||||
|
||||
@@ -6,6 +6,7 @@ using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.BusinessLogicsContractsTests;
|
||||
|
||||
@@ -20,7 +21,7 @@ internal class ProductBusinessLogicContractTests
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_productStorageContract = new Mock<IProductStorageContract>();
|
||||
_productBusinessLogicContract = new ProductBusinessLogicContract(_productStorageContract.Object, new Mock<ILogger>().Object);
|
||||
_productBusinessLogicContract = new ProductBusinessLogicContract(_productStorageContract.Object, new Mock<ILogger>().Object, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -79,21 +80,11 @@ internal class ProductBusinessLogicContractTests
|
||||
_productStorageContract.Verify(x => x.GetList(It.IsAny<bool>()), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllProducts_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.GetAllProducts(It.IsAny<bool>()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_productStorageContract.Verify(x => x.GetList(It.IsAny<bool>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllProducts_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x => x.GetList(It.IsAny<bool>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
_productStorageContract.Setup(x => x.GetList(It.IsAny<bool>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.GetAllProducts(It.IsAny<bool>()),
|
||||
@@ -164,16 +155,6 @@ internal class ProductBusinessLogicContractTests
|
||||
x.GetHistoryByProductId(It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetProductHistoryByProduct_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.GetProductHistoryByProduct(Guid.NewGuid().ToString()), Throws.TypeOf<NullListException>());
|
||||
_productStorageContract.Verify(x =>
|
||||
x.GetHistoryByProductId(It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
GetProductHistoryByProduct_StorageThrowError_ThrowException_Test()
|
||||
@@ -181,7 +162,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.GetHistoryByProductId(It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.GetProductHistoryByProduct(Guid.NewGuid().ToString()), Throws.TypeOf<StorageException>());
|
||||
@@ -268,9 +249,9 @@ internal class ProductBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
_productStorageContract.Setup(x =>
|
||||
x.GetElementByName(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementByName(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.GetProductByData(Guid.NewGuid().ToString()),
|
||||
@@ -312,7 +293,7 @@ internal class ProductBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<ProductDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
x.AddElement(It.IsAny<ProductDataModel>())).Throws(new ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.InsertProduct(new(Guid.NewGuid().ToString(),
|
||||
@@ -349,7 +330,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<ProductDataModel>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.InsertProduct(new(Guid.NewGuid().ToString(),
|
||||
@@ -388,7 +369,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<ProductDataModel>())).Throws(new
|
||||
ElementNotFoundException(""));
|
||||
ElementNotFoundException("", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.UpdateProduct(new(Guid.NewGuid().ToString(),
|
||||
@@ -404,7 +385,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<ProductDataModel>())).Throws(new
|
||||
ElementExistsException("Data", "Data"));
|
||||
ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.UpdateProduct(new(Guid.NewGuid().ToString(),
|
||||
@@ -440,7 +421,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<ProductDataModel>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.UpdateProduct(new(Guid.NewGuid().ToString(),
|
||||
@@ -471,7 +452,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
var id = Guid.NewGuid().ToString();
|
||||
_productStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id));
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id, StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.DeleteProduct(Guid.NewGuid().ToString()),
|
||||
@@ -509,7 +490,7 @@ internal class ProductBusinessLogicContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_productBusinessLogicContract.DeleteProduct(Guid.NewGuid().ToString()),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Moq;
|
||||
using North_Bridge_BusinessLogics.Implementations;
|
||||
@@ -6,8 +7,10 @@ using North_Bridge_BusinessLogics.OfficePackage;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Enums;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.BusinessLogicsContractsTests;
|
||||
|
||||
@@ -37,7 +40,7 @@ internal class ReportContractTests
|
||||
_baseWordBuilder = new Mock<BaseWordBuilder>();
|
||||
_baseExcelBuilder = new Mock<BaseExcelBuilder>();
|
||||
_basePdfBuilder = new Mock<BasePdfBuilder>();
|
||||
_reportContract = new ReportContract(_productStorageContract.Object, _saleStorageContract.Object, _salaryStorageContract.Object, _baseWordBuilder.Object, _baseExcelBuilder.Object, _basePdfBuilder.Object, new Mock<ILogger>().Object);
|
||||
_reportContract = new ReportContract(_productStorageContract.Object, _saleStorageContract.Object, _salaryStorageContract.Object, _baseWordBuilder.Object, _baseExcelBuilder.Object, _basePdfBuilder.Object, new Mock<ILogger>().Object, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
@@ -105,7 +108,7 @@ internal class ReportContractTests
|
||||
//Arrange
|
||||
_productStorageContract.Setup(x =>
|
||||
x.GetHistoriesListAsync(It.IsAny<CancellationToken>()))
|
||||
.ThrowsAsync(new StorageException(new InvalidOperationException()));
|
||||
.ThrowsAsync(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
|
||||
//Act & Assert
|
||||
Assert.That(async () => await
|
||||
@@ -135,15 +138,19 @@ internal class ReportContractTests
|
||||
new(Id2, 65, DateTime.UtcNow, Product2)
|
||||
};
|
||||
|
||||
// Настройка моков
|
||||
_productStorageContract.Setup(x => x.GetHistoriesListAsync(It.IsAny<CancellationToken>()))
|
||||
.Returns(Task.FromResult(histories));
|
||||
.ReturnsAsync(histories);
|
||||
|
||||
// Ожидаемые заголовки таблицы
|
||||
var expectedHeaders = new[] { "value", "value", "value" };
|
||||
|
||||
_baseWordBuilder.Setup(x => x.AddHeader(It.IsAny<string>())).Returns(_baseWordBuilder.Object);
|
||||
_baseWordBuilder.Setup(x => x.AddParagraph(It.IsAny<string>())).Returns(_baseWordBuilder.Object);
|
||||
|
||||
var countRows = 0;
|
||||
string[] firstRow = [];
|
||||
string[] secondRow = [];
|
||||
string[] firstRow = Array.Empty<string>();
|
||||
string[] secondRow = Array.Empty<string>();
|
||||
|
||||
_baseWordBuilder.Setup(x => x.AddTable(It.IsAny<int[]>(),
|
||||
It.IsAny<List<string[]>>()))
|
||||
@@ -167,17 +174,21 @@ internal class ReportContractTests
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
// 1 заголовок + 2 тура (name1 и name2) + 5 записей истории
|
||||
// Проверяем количество строк:
|
||||
// 1 заголовок + 2 продукта (name1 и name2) + 5 записей истории = 8 строк
|
||||
Assert.That(countRows, Is.EqualTo(8));
|
||||
|
||||
// Проверяем заголовки таблицы
|
||||
Assert.That(firstRow, Has.Length.EqualTo(3));
|
||||
Assert.That(firstRow[0], Is.EqualTo(expectedHeaders[0]));
|
||||
Assert.That(firstRow[1], Is.EqualTo(expectedHeaders[1]));
|
||||
Assert.That(firstRow[2], Is.EqualTo(expectedHeaders[2]));
|
||||
|
||||
// Проверяем первую строку с данными
|
||||
Assert.That(secondRow, Has.Length.EqualTo(3));
|
||||
|
||||
Assert.That(firstRow[0], Is.EqualTo("Название продукта"));
|
||||
Assert.That(firstRow[1], Is.EqualTo("Старая цена"));
|
||||
|
||||
Assert.That(secondRow[0], Is.EqualTo("name1"));
|
||||
Assert.That(secondRow[1], Is.EqualTo(""));
|
||||
Assert.That(secondRow[2], Is.EqualTo(""));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -235,7 +246,7 @@ internal class ReportContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x => x.GetListAsync(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<CancellationToken>())).Throws(new
|
||||
StorageException(new InvalidOperationException()));
|
||||
StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(async () => await
|
||||
_reportContract.GetDataSaleByPeriodAsync(DateTime.UtcNow.AddDays(-1),
|
||||
@@ -247,29 +258,24 @@ internal class ReportContractTests
|
||||
[Test]
|
||||
public async Task CreateDocumentSalesByPeriod_ShouldeSuccess_Test()
|
||||
{
|
||||
var porduct1 = new ProductDataModel(Guid.NewGuid().ToString(), "name 1", ProductType.Monitor , 10);
|
||||
var porduct1 = new ProductDataModel(Guid.NewGuid().ToString(), "name 1", ProductType.Monitor, 10);
|
||||
var porduct2 = new ProductDataModel(Guid.NewGuid().ToString(), "name 2", ProductType.Monitor, 10);
|
||||
_saleStorageContract.Setup(x => x.GetListAsync(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(new
|
||||
List<SaleDataModel>()
|
||||
_saleStorageContract.Setup(x => x.GetListAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>())).Returns(Task.FromResult(new List<SaleDataModel>()
|
||||
{
|
||||
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [new ProductForSaleDataModel("",
|
||||
porduct1.Id, 10, 10, porduct1), new ProductForSaleDataModel("", porduct2.Id, 10, 10, porduct2)]),
|
||||
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [new ProductForSaleDataModel("", porduct2.Id, 10, 10, porduct2)])
|
||||
}));
|
||||
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [new ProductForSaleDataModel("", porduct1.Id, 10, 10, porduct1), new ProductForSaleDataModel("", porduct2.Id, 10, 10, porduct2)]),
|
||||
new(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, [new ProductForSaleDataModel("", porduct2.Id, 10, 10, porduct2)])
|
||||
}));
|
||||
_baseExcelBuilder.Setup(x => x.AddHeader(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>())).Returns(_baseExcelBuilder.Object);
|
||||
_baseExcelBuilder.Setup(x => x.AddParagraph(It.IsAny<string>(), It.IsAny<int>())).Returns(_baseExcelBuilder.Object);
|
||||
var countRows = 0;
|
||||
string[] firstRow = [];
|
||||
string[] secondRow = [];
|
||||
string[] thirdRow = [];
|
||||
_baseExcelBuilder.Setup(x => x.AddTable(It.IsAny<int[]>(), It.IsAny<List<string[]>>()))
|
||||
.Callback((int[] widths, List<string[]> data) =>
|
||||
{
|
||||
countRows = data.Count;
|
||||
firstRow = data[0];
|
||||
secondRow = data[1];
|
||||
thirdRow = data[2];
|
||||
firstRow = data[1];
|
||||
secondRow = data[2];
|
||||
})
|
||||
.Returns(_baseExcelBuilder.Object);
|
||||
//Act
|
||||
@@ -283,27 +289,13 @@ internal class ReportContractTests
|
||||
});
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(firstRow[0], Is.EqualTo("Сотрудник"));
|
||||
Assert.That(firstRow[1], Is.EqualTo("Дата"));
|
||||
Assert.That(firstRow[2], Is.EqualTo("Сумма"));
|
||||
Assert.That(firstRow[3], Is.EqualTo("Товар"));
|
||||
Assert.That(firstRow[4], Is.EqualTo("Кол-во"));
|
||||
});
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(firstRow[1], Is.EqualTo(200.ToString("N2")));
|
||||
Assert.That(firstRow[2], Is.Empty);
|
||||
Assert.That(firstRow[3], Is.Empty);
|
||||
Assert.That(secondRow[0], Is.Empty);
|
||||
Assert.That(secondRow[1], Is.Not.Empty);
|
||||
Assert.That(secondRow[2], Is.EqualTo(200.ToString("N2")));
|
||||
Assert.That(secondRow[3], Is.Empty);
|
||||
Assert.That(secondRow[4], Is.Empty);
|
||||
});
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(thirdRow[0], Is.Empty);
|
||||
Assert.That(thirdRow[1], Is.Empty);
|
||||
Assert.That(thirdRow[2], Is.Empty);
|
||||
Assert.That(thirdRow[3], Is.EqualTo(porduct1.ProductName));
|
||||
Assert.That(thirdRow[4], Is.EqualTo(10.ToString("N2")));
|
||||
Assert.That(secondRow[1], Is.Empty);
|
||||
Assert.That(secondRow[2], Is.EqualTo(porduct1.ProductName));
|
||||
Assert.That(secondRow[3], Is.EqualTo(10.ToString("N2")));
|
||||
});
|
||||
_saleStorageContract.Verify(x => x.GetListAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<CancellationToken>()), Times.Once);
|
||||
_baseExcelBuilder.Verify(x => x.AddHeader(It.IsAny<string>(), It.IsAny<int>(), It.IsAny<int>()), Times.Once);
|
||||
@@ -394,7 +386,7 @@ internal class ReportContractTests
|
||||
_salaryStorageContract.Setup(x =>
|
||||
x.GetListAsync(It.IsAny<DateTime>(), It.IsAny<DateTime>(),
|
||||
It.IsAny<CancellationToken>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(async () => await
|
||||
_reportContract.GetDataSalaryByPeriodAsync(DateTime.UtcNow.AddDays(-1),
|
||||
|
||||
@@ -37,7 +37,7 @@ internal class SalaryBusinessLogicContractTests
|
||||
_workerStorageContract = new Mock<IWorkerStorageContract>();
|
||||
|
||||
_salaryBusinessLogicContract = new SalaryBusinessLogicContract(_salaryStorageContract.Object,
|
||||
_saleStorageContract.Object, _postStorageContract.Object, _workerStorageContract.Object, new Mock<ILogger>().Object, _salaryConfigurationTest);
|
||||
_saleStorageContract.Object, _postStorageContract.Object, _workerStorageContract.Object, new Mock<ILogger>().Object, _salaryConfigurationTest, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -106,23 +106,12 @@ internal class SalaryBusinessLogicContractTests
|
||||
It.IsAny<DateTime>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalaries_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_salaryBusinessLogicContract.GetAllSalariesByPeriod(DateTime.UtcNow,
|
||||
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<NullListException>());
|
||||
_salaryStorageContract.Verify(x => x.GetList(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalaries_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_salaryStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
It.IsAny<DateTime>(), It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_salaryBusinessLogicContract.GetAllSalariesByPeriod(DateTime.UtcNow,
|
||||
@@ -216,25 +205,13 @@ internal class SalaryBusinessLogicContractTests
|
||||
It.IsAny<DateTime>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalariesByWorker_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_salaryBusinessLogicContract.GetAllSalariesByPeriodByWorker(DateTime.UtcNow,
|
||||
DateTime.UtcNow.AddDays(1), Guid.NewGuid().ToString()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_salaryStorageContract.Verify(x => x.GetList(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalariesByWorker_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_salaryStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(),
|
||||
It.IsAny<DateTime>(), It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_salaryBusinessLogicContract.GetAllSalariesByPeriodByWorker(DateTime.UtcNow,
|
||||
@@ -320,52 +297,13 @@ internal class SalaryBusinessLogicContractTests
|
||||
Assert.That(sum, Is.EqualTo(rate));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSalaryByMounth_SaleStorageReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
||||
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Cashier, new PostConfiguration() { Rate = 100 }));
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
||||
.Returns([new WorkerDataModel(workerId, "Test", "example@example.com", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false)]);
|
||||
//Act&Assert
|
||||
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSalaryByMounth_PostStorageReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns([new SaleDataModel(Guid.NewGuid().ToString(), workerId, false, [])]);
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
||||
.Returns([new WorkerDataModel(workerId, "Test", "example@example.com", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false)]);
|
||||
//Act&Assert
|
||||
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSalaryByMounth_WorkerStorageReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns([new SaleDataModel(Guid.NewGuid().ToString(), workerId, false, [])]);
|
||||
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
||||
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Cashier, new PostConfiguration() { Rate = 100 }));
|
||||
//Act&Assert
|
||||
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<NullListException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void CalculateSalaryByMounth_SaleStorageThrowException_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
var workerId = Guid.NewGuid().ToString();
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Throws(new StorageException(new InvalidOperationException()));
|
||||
.Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
||||
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Cashier, new PostConfiguration() { Rate = 100 }));
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
||||
@@ -382,7 +320,7 @@ internal class SalaryBusinessLogicContractTests
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime>(), It.IsAny<DateTime>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Returns([new SaleDataModel(Guid.NewGuid().ToString(), workerId, false, [])]);
|
||||
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
||||
.Throws(new StorageException(new InvalidOperationException()));
|
||||
.Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
||||
.Returns([new WorkerDataModel(workerId, "Test", "example@example.com", Guid.NewGuid().ToString(), DateTime.UtcNow, DateTime.UtcNow, false)]);
|
||||
//Act&Assert
|
||||
@@ -399,7 +337,7 @@ internal class SalaryBusinessLogicContractTests
|
||||
_postStorageContract.Setup(x => x.GetElementById(It.IsAny<string>()))
|
||||
.Returns(new PostDataModel(Guid.NewGuid().ToString(), "name", PostType.Cashier, new PostConfiguration() { Rate = 100 }));
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(), It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>()))
|
||||
.Throws(new StorageException(new InvalidOperationException()));
|
||||
.Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() => _salaryBusinessLogicContract.CalculateSalaryByMounth(DateTime.UtcNow), Throws.TypeOf<StorageException>());
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.BusinessLogicsContractsTests;
|
||||
|
||||
@@ -19,7 +20,7 @@ internal class SaleBusinessLogicContractTests
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_saleStorageContract = new Mock<ISaleStorageContract>();
|
||||
_saleBusinessLogicContract = new SaleBusinessLogicContract(_saleStorageContract.Object, new Mock<ILogger>().Object);
|
||||
_saleBusinessLogicContract = new SaleBusinessLogicContract(_saleStorageContract.Object, new Mock<ILogger>().Object, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -88,24 +89,13 @@ internal class SaleBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalesByPeriod_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByPeriod(DateTime.UtcNow,
|
||||
DateTime.UtcNow.AddDays(1)), Throws.TypeOf<NullListException>());
|
||||
_saleStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalesByPeriod_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Throws(new StorageException(new InvalidOperationException()));
|
||||
.Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByPeriod(DateTime.UtcNow,
|
||||
@@ -204,18 +194,6 @@ internal class SaleBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalesByWorkerByPeriod_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByWorkerByPeriod(Guid.NewGuid().ToString(),
|
||||
DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_saleStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
GetAllSalesByWorkerByPeriod_StorageThrowError_ThrowException_Test()
|
||||
@@ -223,7 +201,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()))
|
||||
.Throws(new StorageException(new InvalidOperationException()));
|
||||
.Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByWorkerByPeriod(Guid.NewGuid().ToString(),
|
||||
@@ -322,25 +300,13 @@ internal class SaleBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllSalesByProductByPeriod_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByProductByPeriod(Guid.NewGuid().ToString()
|
||||
, DateTime.UtcNow, DateTime.UtcNow.AddDays(1)),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_saleStorageContract.Verify(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
GetAllSalesByProductByPeriod_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x => x.GetList(It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
It.IsAny<DateTime?>(), It.IsAny<string>(), It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetAllSalesByProductByPeriod(Guid.NewGuid().ToString(),
|
||||
@@ -410,7 +376,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x =>
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.GetSaleByData(Guid.NewGuid().ToString()),
|
||||
@@ -457,7 +423,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<SaleDataModel>())).Throws(new
|
||||
ElementExistsException("Data", "Data"));
|
||||
ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.InsertSale(new(Guid.NewGuid().ToString(),
|
||||
@@ -495,7 +461,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<SaleDataModel>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.InsertSale(new(Guid.NewGuid().ToString(),
|
||||
@@ -528,7 +494,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
var id = Guid.NewGuid().ToString();
|
||||
_saleStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id));
|
||||
x.DelElement(It.IsAny<string>())).Throws(new ElementNotFoundException(id, StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.CancelSale(Guid.NewGuid().ToString()),
|
||||
@@ -566,7 +532,7 @@ internal class SaleBusinessLogicContractTests
|
||||
//Arrange
|
||||
_saleStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_saleBusinessLogicContract.CancelSale(Guid.NewGuid().ToString()),
|
||||
|
||||
@@ -5,6 +5,7 @@ using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.StoragesContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.BusinessLogicsContractsTests;
|
||||
|
||||
@@ -20,7 +21,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
_workerStorageContract = new Mock<IWorkerStorageContract>();
|
||||
|
||||
_workerBusinessLogicContract = new WorkerBusinessLogicContract(_workerStorageContract.Object, new Mock<ILogger>().Object);
|
||||
_workerBusinessLogicContract = new WorkerBusinessLogicContract(_workerStorageContract.Object, new Mock<ILogger>().Object, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
@@ -87,18 +88,6 @@ internal class WorkerBusinessLogicContractTests
|
||||
null, null, null, null), Times.Exactly(2));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkers_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkers(It.IsAny<bool>()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_workerStorageContract.Verify(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkers_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
@@ -106,7 +95,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkers(It.IsAny<bool>()),
|
||||
@@ -205,18 +194,6 @@ internal class WorkerBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkersByPost_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByPost(Guid.NewGuid().ToString(),
|
||||
It.IsAny<bool>()), Throws.TypeOf<NullListException>());
|
||||
_workerStorageContract.Verify(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkersByPost_StorageThrowError_ThrowException_Test()
|
||||
{
|
||||
@@ -224,7 +201,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByPost(Guid.NewGuid().ToString(),
|
||||
@@ -315,19 +292,6 @@ internal class WorkerBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkersByBirthDate_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByBirthDate(DateTime.UtcNow,
|
||||
DateTime.UtcNow.AddDays(1), It.IsAny<bool>()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_workerStorageContract.Verify(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
GetAllWorkersByBirthDate_StorageThrowError_ThrowException_Test()
|
||||
@@ -336,7 +300,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByBirthDate(DateTime.UtcNow,
|
||||
@@ -431,19 +395,6 @@ internal class WorkerBusinessLogicContractTests
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Never);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetAllWorkersByEmploymentDate_ReturnNull_ThrowException_Test()
|
||||
{
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByEmploymentDate(DateTime.UtcNow,
|
||||
DateTime.UtcNow.AddDays(1), It.IsAny<bool>()),
|
||||
Throws.TypeOf<NullListException>());
|
||||
_workerStorageContract.Verify(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>()), Times.Once);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void
|
||||
GetAllWorkersByEmploymentDate_StorageThrowError_ThrowException_Test()
|
||||
@@ -451,7 +402,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x => x.GetList(It.IsAny<bool>(),
|
||||
It.IsAny<string?>(), It.IsAny<DateTime?>(), It.IsAny<DateTime?>(),
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
It.IsAny<DateTime?>(), It.IsAny<DateTime?>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetAllWorkersByEmploymentDate(DateTime.UtcNow,
|
||||
@@ -546,9 +497,9 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementById(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.GetElementByFIO(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.GetElementByFIO(It.IsAny<string>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.GetWorkerByData(Guid.NewGuid().ToString()),
|
||||
@@ -592,7 +543,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<WorkerDataModel>())).Throws(new ElementExistsException("Data", "Data"));
|
||||
x.AddElement(It.IsAny<WorkerDataModel>())).Throws(new ElementExistsException("Data", "Data", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.InsertWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com",
|
||||
@@ -628,7 +579,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.AddElement(It.IsAny<WorkerDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.AddElement(It.IsAny<WorkerDataModel>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.InsertWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com",
|
||||
@@ -668,7 +619,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<WorkerDataModel>())).Throws(new ElementNotFoundException(""));
|
||||
x.UpdElement(It.IsAny<WorkerDataModel>())).Throws(new ElementNotFoundException("", StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.UpdateWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com",
|
||||
@@ -704,7 +655,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
{
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.UpdElement(It.IsAny<WorkerDataModel>())).Throws(new StorageException(new InvalidOperationException()));
|
||||
x.UpdElement(It.IsAny<WorkerDataModel>())).Throws(new StorageException(new InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.UpdateWorker(new(Guid.NewGuid().ToString(), "fio", "example@example.com",
|
||||
@@ -736,7 +687,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
//Arrange
|
||||
var id = Guid.NewGuid().ToString();
|
||||
_workerStorageContract.Setup(x => x.DelElement(It.Is((string x) => x != id)))
|
||||
.Throws(new ElementNotFoundException(id));
|
||||
.Throws(new ElementNotFoundException(id, StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.DeleteWorker(Guid.NewGuid().ToString()),
|
||||
@@ -774,7 +725,7 @@ internal class WorkerBusinessLogicContractTests
|
||||
//Arrange
|
||||
_workerStorageContract.Setup(x =>
|
||||
x.DelElement(It.IsAny<string>())).Throws(new StorageException(new
|
||||
InvalidOperationException()));
|
||||
InvalidOperationException(), StringLocalizerMockCreator.GetObject()));
|
||||
//Act&Assert
|
||||
Assert.That(() =>
|
||||
_workerBusinessLogicContract.DeleteWorker(Guid.NewGuid().ToString()),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using North_Bridge_Contract.Enums;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
[TestFixture]
|
||||
@@ -11,10 +12,10 @@ internal class PostDataModelTests
|
||||
public void IdIsNullOrEmptyTest()
|
||||
{
|
||||
var post = CreateDataModel(null, "name", PostType.Consultant, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(string.Empty, "name", PostType.Consultant, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -22,7 +23,7 @@ internal class PostDataModelTests
|
||||
public void IdIsNotGuidTest()
|
||||
{
|
||||
var post = CreateDataModel("id", "name", PostType.Consultant, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -31,11 +32,11 @@ internal class PostDataModelTests
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), null,
|
||||
PostType.Consultant, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(),
|
||||
string.Empty, PostType.Consultant, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -44,7 +45,7 @@ internal class PostDataModelTests
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name",
|
||||
PostType.None, new PostConfiguration() { Rate = 10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -53,7 +54,7 @@ internal class PostDataModelTests
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name",
|
||||
PostType.Cashier, null);
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -62,11 +63,11 @@ internal class PostDataModelTests
|
||||
{
|
||||
var post = CreateDataModel(Guid.NewGuid().ToString(), "name",
|
||||
PostType.Cashier, new PostConfiguration() { Rate = 0 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
post = CreateDataModel(Guid.NewGuid().ToString(), "name",
|
||||
PostType.Cashier, new PostConfiguration() { Rate = -10 });
|
||||
Assert.That(() => post.Validate(),
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -78,7 +79,7 @@ internal class PostDataModelTests
|
||||
var postType = PostType.Consultant;
|
||||
var configuration = new PostConfiguration() { Rate = 10 };
|
||||
var post = CreateDataModel(postId, postName, postType, configuration);
|
||||
Assert.That(() => post.Validate(), Throws.Nothing);
|
||||
Assert.That(() => post.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(post.Id, Is.EqualTo(postId));
|
||||
@@ -86,6 +87,7 @@ internal class PostDataModelTests
|
||||
Assert.That(post.PostType, Is.EqualTo(postType));
|
||||
Assert.That(post.ConfigurationModel, Is.EqualTo(configuration));
|
||||
Assert.That(post.ConfigurationModel.Rate, Is.EqualTo(configuration.Rate));
|
||||
Assert.That(post.ConfigurationModel.CultureName, Is.Not.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Enums;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -11,11 +12,11 @@ internal class ProductDataModelTests
|
||||
public void IdIsNullOrEmptyTest()
|
||||
{
|
||||
var product = CreateDataModel(null, "name", ProductType.Monitor, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
product = CreateDataModel(string.Empty, "name",
|
||||
ProductType.Monitor, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -23,7 +24,7 @@ internal class ProductDataModelTests
|
||||
public void IdIsNotGuidTest()
|
||||
{
|
||||
var product = CreateDataModel("id", "name", ProductType.Monitor, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -32,11 +33,11 @@ internal class ProductDataModelTests
|
||||
{
|
||||
var product = CreateDataModel(Guid.NewGuid().ToString(), null,
|
||||
ProductType.Monitor, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
product = CreateDataModel(Guid.NewGuid().ToString(), string.Empty,
|
||||
ProductType.Monitor, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -45,7 +46,7 @@ internal class ProductDataModelTests
|
||||
{
|
||||
var product = CreateDataModel(Guid.NewGuid().ToString(), null,
|
||||
ProductType.None, 10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -54,10 +55,10 @@ internal class ProductDataModelTests
|
||||
{
|
||||
var product = CreateDataModel(Guid.NewGuid().ToString(), "name",
|
||||
ProductType.Monitor, 0, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
product = CreateDataModel(Guid.NewGuid().ToString(), "name", ProductType.Monitor, -10, false);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -70,7 +71,7 @@ internal class ProductDataModelTests
|
||||
var productPrice = 10;
|
||||
var productIsDelete = false;
|
||||
var product = CreateDataModel(productId, productName, productType, productPrice, productIsDelete);
|
||||
Assert.That(() => product.Validate(), Throws.Nothing);
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(product.Id, Is.EqualTo(productId));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -10,10 +11,10 @@ internal class ProductForSaleDataModelTests
|
||||
public void SaleIdIsNullOrEmptyTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel(null, Guid.NewGuid().ToString(), 10, 10);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
saleProduct = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10, 10);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ internal class ProductForSaleDataModelTests
|
||||
public void SaleIdIsNotGuidTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel("saleId", Guid.NewGuid().ToString(), 10, 10);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -29,10 +30,10 @@ internal class ProductForSaleDataModelTests
|
||||
public void ProductIdIsNullOrEmptyTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), null, 10, 1000);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
saleProduct = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), 10, 10);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -40,7 +41,7 @@ internal class ProductForSaleDataModelTests
|
||||
public void ProductIdIsNotGuidTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), "productId", 10, 1000);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -48,10 +49,10 @@ internal class ProductForSaleDataModelTests
|
||||
public void CountIsLessOrZeroTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 0, 1000);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), -10, 1000);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -59,10 +60,10 @@ internal class ProductForSaleDataModelTests
|
||||
public void PriceIsLessOrZeroTest()
|
||||
{
|
||||
var saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, 0);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
saleProduct = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), 10, -1000);
|
||||
Assert.That(() => saleProduct.Validate(),
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -74,7 +75,7 @@ internal class ProductForSaleDataModelTests
|
||||
var count = 10;
|
||||
var price = 1000;
|
||||
var saleProduct = CreateDataModel(saleId, productId, count, price);
|
||||
Assert.That(() => saleProduct.Validate(), Throws.Nothing);
|
||||
Assert.That(() => saleProduct.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(saleProduct.SaleId, Is.EqualTo(saleId));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -10,10 +11,10 @@ internal class ProductHistoryDataModelTests
|
||||
public void ProductIdIsNullOrEmptyTest()
|
||||
{
|
||||
var product = CreateDataModel(null, 10);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
product = CreateDataModel(string.Empty, 10);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ internal class ProductHistoryDataModelTests
|
||||
public void ProductIdIsNotGuidTest()
|
||||
{
|
||||
var product = CreateDataModel("id", 10);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -29,10 +30,10 @@ internal class ProductHistoryDataModelTests
|
||||
public void OldPriceIsLessOrZeroTest()
|
||||
{
|
||||
var product = CreateDataModel(Guid.NewGuid().ToString(), 0);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
product = CreateDataModel(Guid.NewGuid().ToString(), -10);
|
||||
Assert.That(() => product.Validate(),
|
||||
Assert.That(() => product.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -42,7 +43,7 @@ internal class ProductHistoryDataModelTests
|
||||
var productId = Guid.NewGuid().ToString();
|
||||
var oldPrice = 10;
|
||||
var productHistory = CreateDataModel(productId, oldPrice);
|
||||
Assert.That(() => productHistory.Validate(), Throws.Nothing);
|
||||
Assert.That(() => productHistory.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(productHistory.ProductId, Is.EqualTo(productId));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -10,10 +11,10 @@ internal class SalaryDataModelTests
|
||||
public void WorkerIdIsEmptyTest()
|
||||
{
|
||||
var salary = CreateDataModel(null, DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(),
|
||||
Assert.That(() => salary.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
salary = CreateDataModel(string.Empty, DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(),
|
||||
Assert.That(() => salary.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ internal class SalaryDataModelTests
|
||||
public void WorkerIdIsNotGuidTest()
|
||||
{
|
||||
var salary = CreateDataModel("workerId", DateTime.Now, 10);
|
||||
Assert.That(() => salary.Validate(),
|
||||
Assert.That(() => salary.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -29,10 +30,10 @@ internal class SalaryDataModelTests
|
||||
public void PriceIsLessOrZeroTest()
|
||||
{
|
||||
var salary = CreateDataModel(Guid.NewGuid().ToString(), DateTime.Now, 0);
|
||||
Assert.That(() => salary.Validate(),
|
||||
Assert.That(() => salary.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
salary = CreateDataModel(Guid.NewGuid().ToString(), DateTime.Now, -10);
|
||||
Assert.That(() => salary.Validate(),
|
||||
Assert.That(() => salary.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -43,11 +44,11 @@ internal class SalaryDataModelTests
|
||||
var salaryDate = DateTime.Now.AddDays(-3).AddMinutes(-5);
|
||||
var workerSalary = 10;
|
||||
var salary = CreateDataModel(workerId, salaryDate, workerSalary);
|
||||
Assert.That(() => salary.Validate(), Throws.Nothing);
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(salary.WorkerId, Is.EqualTo(workerId));
|
||||
Assert.That(salary.SalaryDate, Is.EqualTo(salaryDate));
|
||||
Assert.That(salary.SalaryDate, Is.EqualTo(salaryDate.ToUniversalTime()));
|
||||
Assert.That(salary.Salary, Is.EqualTo(workerSalary));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -10,10 +11,10 @@ internal class SaleDataModelTestscs
|
||||
public void IdIsNullOrEmptyTest()
|
||||
{
|
||||
var sale = CreateDataModel(null, Guid.NewGuid().ToString(), false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
sale = CreateDataModel(string.Empty, Guid.NewGuid().ToString(), false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -21,17 +22,17 @@ internal class SaleDataModelTestscs
|
||||
public void IdIsNotGuidTest()
|
||||
{
|
||||
var sale = CreateDataModel("id", Guid.NewGuid().ToString(), false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void WorkerIdIsNullOrEmptyTest()
|
||||
{
|
||||
var sale = CreateDataModel(Guid.NewGuid().ToString(), null, false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
sale = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -39,7 +40,7 @@ internal class SaleDataModelTestscs
|
||||
public void WorkerIdIsNotGuidTest()
|
||||
{
|
||||
var sale = CreateDataModel(Guid.NewGuid().ToString(), "workerId", false, CreateSubDataModel());
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -91,10 +92,10 @@ internal class SaleDataModelTestscs
|
||||
public void ProductsIsNullOrEmptyTest()
|
||||
{
|
||||
var sale = CreateDataModel(Guid.NewGuid().ToString(), Guid.NewGuid().ToString(), false, null);
|
||||
Assert.That(() => sale.Validate(),
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
sale = CreateDataModel(Guid.NewGuid().ToString(),Guid.NewGuid().ToString(), false, []);
|
||||
Assert.That(() => sale.Validate(), Throws.TypeOf<ValidationException>());
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()), Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
[Test]
|
||||
@@ -106,7 +107,7 @@ internal class SaleDataModelTestscs
|
||||
var products = CreateSubDataModel();
|
||||
var sale = CreateDataModel(saleId, workerId,
|
||||
isCancel, products);
|
||||
Assert.That(() => sale.Validate(), Throws.Nothing);
|
||||
Assert.That(() => sale.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(sale.Id, Is.EqualTo(saleId));
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
|
||||
namespace North_Bridge_Tests.DataModelsTests;
|
||||
|
||||
@@ -10,10 +11,10 @@ internal class WorkerDataModelTests
|
||||
public void IdIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(null, "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
worker = CreateDataModel(string.Empty, "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -21,7 +22,7 @@ internal class WorkerDataModelTests
|
||||
public void IdIsNotGuidTest()
|
||||
{
|
||||
var worker = CreateDataModel("id", "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -29,10 +30,10 @@ internal class WorkerDataModelTests
|
||||
public void FIOIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), null, "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), string.Empty, "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -40,10 +41,10 @@ internal class WorkerDataModelTests
|
||||
public void PostIdIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", null, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", string.Empty, DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ internal class WorkerDataModelTests
|
||||
public void PostIdIsNotGuidTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", "postId", DateTime.Now.AddYears(-18), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
|
||||
}
|
||||
@@ -60,7 +61,7 @@ internal class WorkerDataModelTests
|
||||
public void BirthDateIsNotCorrectTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(1), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -68,10 +69,10 @@ internal class WorkerDataModelTests
|
||||
public void BirthDateAndEmploymentDateIsNotCorrectTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-18).AddDays(-1), false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example@example.com", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-18), DateTime.Now.AddYears(-16), false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -79,10 +80,10 @@ internal class WorkerDataModelTests
|
||||
public void EmailIsNullOrEmptyTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", null, Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", string.Empty, Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -90,7 +91,7 @@ internal class WorkerDataModelTests
|
||||
public void EmailIsIncorrectTest()
|
||||
{
|
||||
var worker = CreateDataModel(Guid.NewGuid().ToString(), "fio", "example", Guid.NewGuid().ToString(), DateTime.Now.AddYears(-16).AddDays(-1), DateTime.Now, false);
|
||||
Assert.That(() => worker.Validate(),
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()),
|
||||
Throws.TypeOf<ValidationException>());
|
||||
}
|
||||
|
||||
@@ -105,15 +106,18 @@ internal class WorkerDataModelTests
|
||||
var employmentDate = DateTime.Now;
|
||||
var isDelete = false;
|
||||
var worker = CreateDataModel(workerId, fio, Email, postId, birthDate, employmentDate, isDelete);
|
||||
Assert.That(() => worker.Validate(), Throws.Nothing);
|
||||
Assert.That(() => worker.Validate(StringLocalizerMockCreator.GetObject()), Throws.Nothing);
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(worker.Id, Is.EqualTo(workerId));
|
||||
Assert.That(worker.FIO, Is.EqualTo(fio));
|
||||
Assert.That(worker.Email, Is.EqualTo(Email));
|
||||
Assert.That(worker.PostId, Is.EqualTo(postId));
|
||||
Assert.That(worker.BirthDate, Is.EqualTo(birthDate));
|
||||
Assert.That(worker.EmploymentDate, Is.EqualTo(employmentDate));
|
||||
Assert.That(worker.BirthDate,
|
||||
Is.EqualTo(birthDate.ToUniversalTime()));
|
||||
Assert.That(worker.EmploymentDate,
|
||||
Is.EqualTo(employmentDate.ToUniversalTime()));
|
||||
|
||||
Assert.That(worker.IsDeleted, Is.EqualTo(isDelete));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using Microsoft.Extensions.Localization;
|
||||
using Moq;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace North_Bridge_Tests.Infrastructure;
|
||||
|
||||
internal static class StringLocalizerMockCreator
|
||||
{
|
||||
private static Mock<IStringLocalizer<Messages>>? _mockObject = null;
|
||||
|
||||
public static IStringLocalizer<Messages> GetObject()
|
||||
{
|
||||
if (_mockObject is null)
|
||||
{
|
||||
_mockObject = new Mock<IStringLocalizer<Messages>>();
|
||||
_mockObject.Setup(_ => _[It.IsAny<string>()]).Returns(new LocalizedString("name", "value"));
|
||||
}
|
||||
return _mockObject!.Object;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,409 @@
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using Microsoft.AspNetCore.Mvc.Testing;
|
||||
using Microsoft.AspNetCore.TestHost;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using North_Bridge_Contract.BindingModels;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Enums;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using North_Bridge_DataBase;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
using Serilog;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace North_Bridge_Tests.LocalizationTests
|
||||
{
|
||||
internal abstract class BaseLocalizationControllerTest
|
||||
{
|
||||
protected abstract string GetLocale();
|
||||
|
||||
private WebApplicationFactory<Program> _webApplication;
|
||||
|
||||
protected HttpClient HttpClient { get; private set; }
|
||||
|
||||
protected static North_Bridge_DbContext DbContext { get; private set; }
|
||||
|
||||
protected static readonly JsonSerializerOptions JsonSerializerOptions = new() { PropertyNameCaseInsensitive = true };
|
||||
|
||||
private static string _workerId;
|
||||
private static string _productId;
|
||||
private static string _postId;
|
||||
|
||||
[OneTimeSetUp]
|
||||
public void OneTimeSetUp()
|
||||
{
|
||||
_webApplication = new CustomWebApplicationFactory<Program>();
|
||||
HttpClient = _webApplication
|
||||
.WithWebHostBuilder(builder =>
|
||||
{
|
||||
builder.ConfigureTestServices(services =>
|
||||
{
|
||||
using var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
services.AddSingleton(loggerFactory);
|
||||
});
|
||||
})
|
||||
.CreateClient();
|
||||
|
||||
var request = HttpClient.GetAsync("/login/user").GetAwaiter().GetResult();
|
||||
var data = request.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
||||
HttpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {data}");
|
||||
HttpClient.DefaultRequestHeaders.Add("Accept-Language", GetLocale());
|
||||
|
||||
DbContext = _webApplication.Services.GetRequiredService<North_Bridge_DbContext>();
|
||||
DbContext.Database.EnsureDeleted();
|
||||
DbContext.Database.EnsureCreated();
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_workerId = DbContext.InsertWorkerToDatabaseAndReturn(fio: "Worker").Id;
|
||||
_productId = DbContext.InsertProductToDatabaseAndReturn(productName: "Product").Id;
|
||||
_postId = DbContext.InsertPostToDatabaseAndReturn(postName: "Post").PostId;
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
public void TearDown()
|
||||
{
|
||||
DbContext.RemoveSalariesFromDatabase();
|
||||
DbContext.RemoveSalesFromDatabase();
|
||||
DbContext.RemoveWorkersFromDatabase();
|
||||
DbContext.RemovePostsFromDatabase();
|
||||
DbContext.RemoveProductsFromDatabase();
|
||||
}
|
||||
|
||||
[OneTimeTearDown]
|
||||
public void OneTimeTearDown()
|
||||
{
|
||||
DbContext?.Database.EnsureDeleted();
|
||||
DbContext?.Dispose();
|
||||
HttpClient?.Dispose();
|
||||
_webApplication?.Dispose();
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LoadHistories_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var Id1 = Guid.NewGuid().ToString();
|
||||
var Id2 = Guid.NewGuid().ToString();
|
||||
|
||||
var product1 = DbContext.InsertProductToDatabaseAndReturn(Id1, "name1", ProductType.Monitor, 10, false);
|
||||
var product2 = DbContext.InsertProductToDatabaseAndReturn(Id2, "name2", ProductType.Monitor, 10, false);
|
||||
|
||||
DbContext.InsertProductHistoryToDatabaseAndReturn(Id1, 22, DateTime.UtcNow);
|
||||
DbContext.InsertProductHistoryToDatabaseAndReturn(Id2, 21, DateTime.UtcNow);
|
||||
DbContext.InsertProductHistoryToDatabaseAndReturn(Id1, 33, DateTime.UtcNow);
|
||||
DbContext.InsertProductHistoryToDatabaseAndReturn(Id1, 32, DateTime.UtcNow);
|
||||
DbContext.InsertProductHistoryToDatabaseAndReturn(Id2, 65, DateTime.UtcNow);
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync("/api/report/GetHistories");
|
||||
//Assert
|
||||
await AssertStreamAsync(response, $"file-{GetLocale()}.docx");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LoadSales_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var worker = DbContext.InsertWorkerToDatabaseAndReturn();
|
||||
var product1 = DbContext.InsertProductToDatabaseAndReturn(productName: "name 1");
|
||||
var product2 = DbContext.InsertProductToDatabaseAndReturn(productName: "name 2");
|
||||
DbContext.InsertSaleToDatabaseAndReturn(worker.Id, products: [(product1.Id, 10, 1.1), (product2.Id, 10, 1.1)]);
|
||||
DbContext.InsertSaleToDatabaseAndReturn(worker.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}");
|
||||
//Assert
|
||||
await AssertStreamAsync(response, $"file-{GetLocale()}.xlsx");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task LoadSalary_WhenHaveRecords_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var post = DbContext.InsertPostToDatabaseAndReturn();
|
||||
var worker1 = DbContext.InsertWorkerToDatabaseAndReturn(fio: "fio 1", postId: post.PostId).AddPost(post);
|
||||
var worker2 = DbContext.InsertWorkerToDatabaseAndReturn(fio: "fio 2", postId: post.PostId).AddPost(post);
|
||||
DbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, workerSalary: 100, salaryDate: DateTime.UtcNow.AddDays(-10));
|
||||
DbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, workerSalary: 1000, salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||
DbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, workerSalary: 200, salaryDate: DateTime.UtcNow.AddDays(5));
|
||||
DbContext.InsertSalaryToDatabaseAndReturn(worker2.Id, workerSalary: 500, salaryDate: DateTime.UtcNow.AddDays(-5));
|
||||
DbContext.InsertSalaryToDatabaseAndReturn(worker2.Id, workerSalary: 300, salaryDate: DateTime.UtcNow.AddDays(-3));
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync($"/api/report/loadsalary?fromDate={DateTime.Now.AddDays(-7):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}");
|
||||
//Assert
|
||||
await AssertStreamAsync(response, $"file-{GetLocale()}.pdf");
|
||||
}
|
||||
|
||||
private static async Task AssertStreamAsync(HttpResponseMessage response, string fileNameForSave = "")
|
||||
{
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
using var data = await response.Content.ReadAsStreamAsync();
|
||||
Assert.That(data, Is.Not.Null);
|
||||
Assert.That(data.Length, Is.GreaterThan(0));
|
||||
await SaveStreamAsync(data, fileNameForSave);
|
||||
}
|
||||
|
||||
private static async Task SaveStreamAsync(Stream stream, string fileName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var path = Path.Combine(Directory.GetCurrentDirectory(), fileName);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
}
|
||||
stream.Position = 0;
|
||||
using var fileStream = new FileStream(path, FileMode.OpenOrCreate);
|
||||
await stream.CopyToAsync(fileStream);
|
||||
}
|
||||
|
||||
protected abstract string MessageElementNotFound();
|
||||
|
||||
|
||||
|
||||
[TestCase("posts")]
|
||||
[TestCase("products/getrecord")]
|
||||
[TestCase("sales/getrecord")]
|
||||
[TestCase("workers/getrecord")]
|
||||
public async Task Api_GetElement_NotFound_Test(string path)
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync($"/api/{path}/{Guid.NewGuid()}");
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await response.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageElementNotFound()));
|
||||
}
|
||||
|
||||
[TestCase("posts")]
|
||||
[TestCase("products/delete")]
|
||||
[TestCase("workers/delete")]
|
||||
public async Task Api_DelElement_NotFound_Test(string path)
|
||||
{
|
||||
//Act
|
||||
var response = await HttpClient.DeleteAsync($"/api/{path}/{Guid.NewGuid()}");
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await response.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageElementNotFound()));
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> TestDataElementExists()
|
||||
{
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreatePostModel();
|
||||
DbContext.InsertPostToDatabaseAndReturn(model.Id);
|
||||
return model;
|
||||
}, "posts");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateProductModel();
|
||||
DbContext.InsertProductToDatabaseAndReturn( model.Id);
|
||||
return model;
|
||||
}, "products/register");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateWorkerModel(_postId);
|
||||
DbContext.InsertWorkerToDatabaseAndReturn(model.Id, postId: _postId);
|
||||
return model;
|
||||
}, "workers/register");
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> TestDataIdIncorrect()
|
||||
{
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreatePostModel();
|
||||
model.Id = "ne Id";
|
||||
return model;
|
||||
}, "posts");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateProductModel();
|
||||
model.Id = "ne Id";
|
||||
return model;
|
||||
}, "products/register");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateWorkerModel(_postId);
|
||||
model.Id = "ne Id";
|
||||
return model;
|
||||
}, "workers/register");
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> TestDataValidationErrorIdIsEmpty()
|
||||
{
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreatePostModel();
|
||||
model.Id = "";
|
||||
return model;
|
||||
}, "posts");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateProductModel(Guid.NewGuid().ToString());
|
||||
model.Id = "";
|
||||
return model;
|
||||
}, "products/changeinfo/");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateWorkerModel(_postId);
|
||||
model.Id = "";
|
||||
return model;
|
||||
}, "workers/changeinfo/");
|
||||
}
|
||||
|
||||
private static IEnumerable<TestCaseData> TestDataValidationErrorIdIsNotGuid()
|
||||
{
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreatePostModel();
|
||||
model.Id = "id";
|
||||
return model;
|
||||
}, "posts");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateProductModel(Guid.NewGuid().ToString());
|
||||
model.Id = "id";
|
||||
return model;
|
||||
}, "products/changeinfo/");
|
||||
yield return new TestCaseData(() => {
|
||||
var model = CreateWorkerModel(_postId);
|
||||
model.Id = "id";
|
||||
return model;
|
||||
}, "workers/changeinfo/");
|
||||
}
|
||||
|
||||
|
||||
private static IEnumerable<TestCaseData> TestDataValidationErrorStringIsEmpty()
|
||||
{
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateWorkerModel(_postId);
|
||||
model.FIO = "";
|
||||
return model;
|
||||
}, "workers/changeinfo/");
|
||||
yield return new TestCaseData(() =>
|
||||
{
|
||||
var model = CreateProductModel(Guid.NewGuid().ToString());
|
||||
model.ProductName = "";
|
||||
return model;
|
||||
}, "products/changeinfo/");
|
||||
}
|
||||
|
||||
protected abstract string MessageElementExists();
|
||||
protected abstract string MessageElementIdIncorrect();
|
||||
protected abstract string MessageValidationErrorIDIsEmpty();
|
||||
protected abstract string MessageValidationErrorIDIsNotGuid();
|
||||
protected abstract string MessageValidationStringIsEmpty();
|
||||
protected abstract string MessageElemenValidationErrorPostNameEmpty();
|
||||
protected abstract string MessageElemenValidationErrorFioISEmpty();
|
||||
|
||||
|
||||
[TestCaseSource(nameof(TestDataValidationErrorIdIsEmpty))]
|
||||
public async Task Api_Put_ValidationError_IdIsEmpty_ShouldBadRequest_Test(Func<object> createModel, string path)
|
||||
{
|
||||
//Arrange
|
||||
var model = createModel();
|
||||
//Act
|
||||
var responseWithIdIncorrect = await HttpClient.PutAsync($"/api/{path}", MakeContent(model));
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await responseWithIdIncorrect.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageValidationErrorIDIsEmpty()));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TestDataElementExists))]
|
||||
public async Task Api_Post_WhenHaveRecordWithSameId_ShouldBadRequest_Test(Func<object> createModel, string path)
|
||||
{
|
||||
//Arrange
|
||||
var model = createModel();
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/{path}", MakeContent(model));
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await response.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageElementExists()));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TestDataIdIncorrect))]
|
||||
public async Task Api_Post_WhenDataIsIncorrect_ShouldBadRequest_Test(Func<object> createModel, string path)
|
||||
{
|
||||
//Arrange
|
||||
var model = createModel();
|
||||
|
||||
//Act
|
||||
var responseWithIdIncorrect = await HttpClient.PostAsync($"/api/{path}", MakeContent(model));
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await responseWithIdIncorrect.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageElementIdIncorrect()));
|
||||
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TestDataValidationErrorIdIsNotGuid))]
|
||||
public async Task Api_Put_ValidationError_IIsNotGuid_ShouldBadRequest_Test(Func<object> createModel, string path)
|
||||
{
|
||||
//Arrange
|
||||
var model = createModel();
|
||||
//Act
|
||||
var responseWithIdIncorrect = await HttpClient.PutAsync($"/api/{path}", MakeContent(model));
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await responseWithIdIncorrect.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageValidationErrorIDIsNotGuid()));
|
||||
}
|
||||
|
||||
[TestCaseSource(nameof(TestDataValidationErrorStringIsEmpty))]
|
||||
public async Task Api_Put_ValidationError_StringIsEmpty_ShouldBadRequest_Test(Func<object> createModel, string path)
|
||||
{
|
||||
//Arrange
|
||||
var model = createModel();
|
||||
//Act
|
||||
var responseWithIdIncorrect = await HttpClient.PutAsync($"/api/{path}", MakeContent(model));
|
||||
//Assert
|
||||
Assert.That(JToken.Parse(await responseWithIdIncorrect.Content.ReadAsStringAsync()).ToString(), Does.StartWith(MessageValidationStringIsEmpty()));
|
||||
}
|
||||
|
||||
private static StringContent MakeContent(object model) => new(JsonSerializer.Serialize(model), Encoding.UTF8, "application/json");
|
||||
|
||||
private static PostBindingModel CreatePostModel(string? postId = null, string postName = "name", PostType postType = PostType.Consultant, string? configuration = null)
|
||||
=> new()
|
||||
{
|
||||
Id = postId ?? Guid.NewGuid().ToString(),
|
||||
PostName = postName,
|
||||
PostType = postType.ToString(),
|
||||
ConfigurationJson = configuration ?? JsonSerializer.Serialize(new PostConfiguration() { Rate = 10 })
|
||||
};
|
||||
|
||||
private static ProductBindingModel CreateProductModel(string? id = null, string productName = "name", ProductType productType = ProductType.Monitor, double price = 1)
|
||||
=> new()
|
||||
{
|
||||
Id = id ?? Guid.NewGuid().ToString(),
|
||||
ProductName = productName,
|
||||
ProductType = productType.ToString(),
|
||||
Price = price
|
||||
};
|
||||
|
||||
private static SaleBindingModel CreateSaleModel(string workerId, string productId, string? id = null, int count = 1, double price = 1.1)
|
||||
{
|
||||
var saleId = id ?? Guid.NewGuid().ToString();
|
||||
return new()
|
||||
{
|
||||
Id = saleId,
|
||||
WorkerId = workerId,
|
||||
Products = [new ProductForSaleBindingModel { SaleId = saleId, ProductId = productId, Count = count, Price = price }]
|
||||
};
|
||||
}
|
||||
|
||||
private static WorkerBindingModel CreateWorkerModel(string postId, string? id = null, string fio = "fio", string email = "example@example.com", DateTime? birthDate = null, DateTime? employmentDate = null)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Id = id ?? Guid.NewGuid().ToString(),
|
||||
FIO = fio,
|
||||
Email = email,
|
||||
BirthDate = birthDate ?? DateTime.UtcNow.AddYears(-22),
|
||||
EmploymentDate = employmentDate ?? DateTime.UtcNow.AddDays(-5),
|
||||
PostId = postId
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace North_Bridge_Tests.LocalizationTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class DeDETests : BaseLocalizationControllerTest
|
||||
{
|
||||
protected override string GetLocale() => "de-DE";
|
||||
|
||||
protected override string MessageElementExists() => "Fehler beim Zugriff auf den Datenspeicher";
|
||||
|
||||
protected override string MessageElementIdIncorrect() => "Falsche Daten übergeben: Wert im Feld: Der Wert im Feld \"Id\" ist kein eindeutiger Bezeichnertyp";
|
||||
|
||||
protected override string MessageElementNotFound() => "Element mit Daten";
|
||||
|
||||
protected override string MessageValidationErrorIDIsEmpty() => "Falsche Daten übergeben: Wert im Feld: Der Wert im Feld \"Id\" ist leer";
|
||||
|
||||
protected override string MessageValidationErrorIDIsNotGuid() => "Falsche Daten übergeben: Wert im Feld: Der Wert im Feld \"Id\" ist kein eindeutiger Bezeichnertyp";
|
||||
|
||||
protected override string MessageValidationStringIsEmpty() => "Falsche Daten übergeben: Wert im Feld";
|
||||
|
||||
protected override string MessageElemenValidationErrorPostNameEmpty() => "Falsche Daten wurden übergeben: Der Wert im Feld PostName ist leer";
|
||||
|
||||
protected override string MessageElemenValidationErrorFioISEmpty() => "Falsche Daten übergeben: Der Wert im FIO-Feld ist leer";
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace North_Bridge_Tests.LocalizationTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class DefaultTests : BaseLocalizationControllerTest
|
||||
{
|
||||
protected override string GetLocale() => "bla-BLA";
|
||||
|
||||
protected override string MessageElementExists() => "Уже существует элемент со значением";
|
||||
|
||||
protected override string MessageElementIdIncorrect() => "Переданы неверные данные";
|
||||
|
||||
protected override string MessageElementNotFound() => "Не найден элемент по данным";
|
||||
|
||||
protected override string MessageValidationErrorIDIsEmpty() => "Переданы неверные данные: Значение в поле Id пусто";
|
||||
|
||||
protected override string MessageValidationErrorIDIsNotGuid() => "Переданы неверные данные: Значение в поле Id, не является типом уникального идентификатора";
|
||||
|
||||
protected override string MessageValidationStringIsEmpty() => "Переданы неверные данные: Значение в поле";
|
||||
|
||||
protected override string MessageElemenValidationErrorPostNameEmpty() => "Переданы неверные данные: Значение в поле PostName пусто";
|
||||
|
||||
protected override string MessageElemenValidationErrorFioISEmpty() => "Переданы неверные данные: Значение в поле FIO пусто";
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace North_Bridge_Tests.LocalizationTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class EnUSTests : BaseLocalizationControllerTest
|
||||
{
|
||||
protected override string GetLocale() => "en-US";
|
||||
|
||||
protected override string MessageElementExists() => "There is already an element with value";
|
||||
|
||||
protected override string MessageElementIdIncorrect() => "Incorrect data transmitted";
|
||||
|
||||
protected override string MessageElementNotFound() => "Not found element by data";
|
||||
|
||||
protected override string MessageValidationErrorIDIsEmpty() => "Incorrect data transmitted: The value in the Id field is empty";
|
||||
|
||||
protected override string MessageValidationErrorIDIsNotGuid() => "Incorrect data transmitted: The value in the Id field is not a type of unique identifier.";
|
||||
|
||||
protected override string MessageValidationStringIsEmpty() => "Incorrect data transmitted: ";
|
||||
|
||||
protected override string MessageElemenValidationErrorPostNameEmpty() => "Incorrect data transmitted: The value in field PostName is empty";
|
||||
|
||||
protected override string MessageElemenValidationErrorFioISEmpty() => "Incorrect data transmitted: The value in field FIO is empty";
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace North_Bridge_Tests.LocalizationTests;
|
||||
|
||||
[TestFixture]
|
||||
internal class RuRUTests : BaseLocalizationControllerTest
|
||||
{
|
||||
protected override string GetLocale() => "ru-RU";
|
||||
|
||||
protected override string MessageElementExists() => "Уже существует элемент со значением";
|
||||
|
||||
protected override string MessageElementIdIncorrect() => "Переданы неверные данные";
|
||||
|
||||
protected override string MessageElementNotFound() => "Не найден элемент по данным";
|
||||
|
||||
protected override string MessageValidationErrorIDIsEmpty() => "Переданы неверные данные: Значение в поле Id пусто";
|
||||
|
||||
protected override string MessageValidationErrorIDIsNotGuid() => "Переданы неверные данные: Значение в поле Id, не является типом уникального идентификатора";
|
||||
|
||||
protected override string MessageValidationStringIsEmpty() => "Переданы неверные данные: Значение в поле ";
|
||||
|
||||
protected override string MessageElemenValidationErrorPostNameEmpty() => "Переданы неверные данные: Значение в поле PostName пусто";
|
||||
|
||||
protected override string MessageElemenValidationErrorFioISEmpty() => "Переданы неверные данные: Значение в поле FIO пусто";
|
||||
}
|
||||
@@ -19,7 +19,7 @@ internal class PostStorageContractTests : BaseStorageContractTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_postStorageContract = new PostStorageContract(North_Bridge_DbContext);
|
||||
_postStorageContract = new PostStorageContract(North_Bridge_DbContext, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -19,7 +19,7 @@ internal class ProductStorageContractTests : BaseStorageContractTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_productStorageContract = new ProductStorageContract(North_Bridge_DbContext);
|
||||
_productStorageContract = new ProductStorageContract(North_Bridge_DbContext, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -17,7 +17,7 @@ internal class SalaryStorageContractTests : BaseStorageContractTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_salaryStorageContract = new SalaryStorageContract(North_Bridge_DbContext);
|
||||
_salaryStorageContract = new SalaryStorageContract(North_Bridge_DbContext, StringLocalizerMockCreator.GetObject());
|
||||
_worker = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn();
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ internal class SaleStorageContractTests : BaseStorageContractTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_saletStorageContract = new SaleStorageContract(North_Bridge_DbContext);
|
||||
_saletStorageContract = new SaleStorageContract(North_Bridge_DbContext, StringLocalizerMockCreator.GetObject());
|
||||
_worker = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn();
|
||||
_product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,7 @@ internal class WorkerStorageContractTests : BaseStorageContractTest
|
||||
[SetUp]
|
||||
public void SetUp()
|
||||
{
|
||||
_workerStorageContract = new
|
||||
WorkerStorageContract(North_Bridge_DbContext);
|
||||
_workerStorageContract = new WorkerStorageContract(North_Bridge_DbContext, StringLocalizerMockCreator.GetObject());
|
||||
}
|
||||
|
||||
[TearDown]
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using North_Bridge_Contract.Infrastructure.PostConfigurations;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
using North_Bridge_DataBase.Models;
|
||||
using North_Bridge_Tests.Infrastructure;
|
||||
using System;
|
||||
using System.Net;
|
||||
|
||||
namespace North_Bridge_Tests.WebApiControllersTests;
|
||||
@@ -122,7 +124,7 @@ internal class SalaryControllerTests : BaseWebApiControllerTest
|
||||
North_Bridge_DbContext.InsertSalaryToDatabaseAndReturn(worker2.Id, salaryDate: DateTime.UtcNow.AddDays(1).AddMinutes(-5));
|
||||
North_Bridge_DbContext.InsertSalaryToDatabaseAndReturn(worker1.Id, salaryDate: DateTime.UtcNow.AddDays(-2));
|
||||
//Act
|
||||
var response = await HttpClient.GetAsync($"/api/salaries/getworkerrecords?fromDate={DateTime.UtcNow.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={worker1.Id}");
|
||||
var response = await HttpClient.GetAsync($"/api/salaries/getworkerrecords?fromDate={DateTime.Now.AddDays(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1):MM/dd/yyyy HH:mm:ss}&id={worker1.Id}");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var data = await GetModelFromResponseAsync<List<SalaryViewModel>>(response);
|
||||
@@ -158,9 +160,9 @@ internal class SalaryControllerTests : BaseWebApiControllerTest
|
||||
public async Task Calculate_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn(salary: 1000);
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn(config: new() { Rate = 1400 });
|
||||
var worker = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name", postId: post.PostId);
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(price: 100);
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(worker.Id);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
//Act
|
||||
@@ -179,24 +181,19 @@ internal class SalaryControllerTests : BaseWebApiControllerTest
|
||||
[Test]
|
||||
public async Task Calculate_WithSeveralWorkers_ShouldSuccess_Test()
|
||||
{
|
||||
// Arrange
|
||||
var currentDate = DateTime.UtcNow;
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn(salary: 1000);
|
||||
//Arrange
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn();
|
||||
var worker1 = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name 1", postId: post.PostId);
|
||||
var worker2 = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name 2", postId: post.PostId);
|
||||
var worker3 = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name 3", postId: post.PostId);
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(price: 100);
|
||||
|
||||
// Создаём продажи в текущем месяце
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker1.Id, saleDate: currentDate, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker1.Id, saleDate: currentDate, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker2.Id, saleDate: currentDate, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker3.Id, saleDate: currentDate, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
|
||||
// Act
|
||||
var response = await HttpClient.PostAsync($"/api/salaries/calculate?date={currentDate:MM/dd/yyyy}", null);
|
||||
|
||||
// Assert
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(worker1.Id);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker1.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker1.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker2.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker3.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/salaries/calculate?date={DateTime.UtcNow:MM/dd/yyyy}", null);
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
var salaries = North_Bridge_DbContext.Salaries.ToArray();
|
||||
Assert.That(salaries, Has.Length.EqualTo(3));
|
||||
@@ -217,16 +214,16 @@ internal class SalaryControllerTests : BaseWebApiControllerTest
|
||||
public async Task Calculate_WithoutSalesByWorker_ShouldSuccess_Test()
|
||||
{
|
||||
//Arrange
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn(salary: 1000);
|
||||
var post = North_Bridge_DbContext.InsertPostToDatabaseAndReturn(config: new CashierPostConfiguration() { Rate = 100, SalePercent = 0.05 });
|
||||
var worker1 = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name 1", postId: post.PostId);
|
||||
var worker2 = North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "name 2", postId: post.PostId);
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(price: 100);
|
||||
var product = North_Bridge_DbContext.InsertProductToDatabaseAndReturn(worker1.Id);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker1.Id, saleDate: DateTime.UtcNow.AddMonths(-1), sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
North_Bridge_DbContext.InsertSaleToDatabaseAndReturn(worker2.Id, sum: 2000, products: [(product.Id, 10, 1.1)]);
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/salaries/calculate?date={DateTime.UtcNow:MM/dd/yyyy}", null);
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NoContent));
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
|
||||
var salary1 = North_Bridge_DbContext.GetSalariesFromDatabaseByWorkerId(worker1.Id).First().WorkerSalary;
|
||||
var salary2 = North_Bridge_DbContext.GetSalariesFromDatabaseByWorkerId(worker2.Id).First().WorkerSalary;
|
||||
Assert.That(salary1, Is.Not.EqualTo(salary2));
|
||||
@@ -244,6 +241,6 @@ internal class SalaryControllerTests : BaseWebApiControllerTest
|
||||
//Act
|
||||
var response = await HttpClient.PostAsync($"/api/salaries/calculate?date={DateTime.UtcNow:MM/dd/yyyy}", null);
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.NotFound));
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.InternalServerError));
|
||||
}
|
||||
}
|
||||
@@ -168,8 +168,8 @@ internal class WorkerControllerTests : BaseWebApiControllerTest
|
||||
North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "fio 4", birthDate: DateTime.UtcNow.AddYears(-19));
|
||||
//Act
|
||||
var response = await
|
||||
HttpClient.GetAsync($"/api/workers/getbirthdaterecords?fromDate={DateTime.UtcNow.
|
||||
AddYears(-21).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddYears(-20).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||
HttpClient.GetAsync($"/api/workers/getbirthdaterecords?fromDate={DateTime.Now.
|
||||
AddYears(-21).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddYears(-20).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var data = await
|
||||
@@ -202,8 +202,8 @@ internal class WorkerControllerTests : BaseWebApiControllerTest
|
||||
North_Bridge_DbContext.InsertWorkerToDatabaseAndReturn(fio: "fio 4", employmentDate: DateTime.UtcNow.AddDays(2));
|
||||
//Act
|
||||
var response = await
|
||||
HttpClient.GetAsync($"/api/workers/getemploymentrecords?fromDate={DateTime.UtcNow
|
||||
.AddDays(-1).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.UtcNow.AddDays(1).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||
HttpClient.GetAsync($"/api/workers/getemploymentrecords?fromDate={DateTime.Now
|
||||
.AddDays(-1).AddMinutes(-1):MM/dd/yyyy HH:mm:ss}&toDate={DateTime.Now.AddDays(1).AddMinutes(1):MM/dd/yyyy HH:mm:ss}&includeDeleted=true");
|
||||
//Assert
|
||||
Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.OK));
|
||||
var data = await
|
||||
@@ -641,10 +641,8 @@ _post.PostId).AddPost(_post);
|
||||
Assert.That(actual.PostName,
|
||||
Is.EqualTo(expected.Post!.PostName));
|
||||
Assert.That(actual.FIO, Is.EqualTo(expected.FIO));
|
||||
Assert.That(actual.BirthDate.ToString(),
|
||||
Is.EqualTo(expected.BirthDate.ToString()));
|
||||
Assert.That(actual.EmploymentDate.ToString(),
|
||||
Is.EqualTo(expected.EmploymentDate.ToString()));
|
||||
Assert.That(actual.BirthDate.ToUniversalTime().ToString(), Is.EqualTo(expected.BirthDate.ToString()));
|
||||
Assert.That(actual.EmploymentDate.ToUniversalTime().ToString(), Is.EqualTo(expected.EmploymentDate.ToString()));
|
||||
Assert.That(actual.IsDeleted, Is.EqualTo(expected.IsDeleted));
|
||||
});
|
||||
}
|
||||
@@ -671,10 +669,8 @@ _post.PostId).AddPost(_post);
|
||||
Assert.That(actual.PostId, Is.EqualTo(expected.PostId));
|
||||
Assert.That(actual.FIO, Is.EqualTo(expected.FIO));
|
||||
Assert.That(actual.Email, Is.EqualTo(expected.Email));
|
||||
Assert.That(actual.BirthDate.ToString(),
|
||||
Is.EqualTo(expected.BirthDate.ToString()));
|
||||
Assert.That(actual.EmploymentDate.ToString(),
|
||||
Is.EqualTo(expected.EmploymentDate.ToString()));
|
||||
Assert.That(actual.BirthDate.ToString(), Is.EqualTo(expected.BirthDate.ToString()));
|
||||
Assert.That(actual.EmploymentDate.ToString(), Is.EqualTo(expected.EmploymentDate.ToString()));
|
||||
Assert.That(!actual.IsDeleted);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BindingModels;
|
||||
@@ -6,15 +7,17 @@ using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
using System.Text.Json;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class PostAdapter : IPostAdapter
|
||||
internal class PostAdapter : IPostAdapter
|
||||
{
|
||||
private readonly IPostBusinessLogicContract _postBusinessLogicContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
@@ -25,7 +28,7 @@ public class PostAdapter : IPostAdapter
|
||||
};
|
||||
|
||||
|
||||
public PostAdapter(IPostBusinessLogicContract postBusinessLogicContract, ILogger<PostAdapter> logger)
|
||||
public PostAdapter(IPostBusinessLogicContract postBusinessLogicContract, IStringLocalizer<Messages> localizer, ILogger<PostAdapter> logger)
|
||||
{
|
||||
_postBusinessLogicContract = postBusinessLogicContract;
|
||||
_logger = logger;
|
||||
@@ -36,6 +39,7 @@ public class PostAdapter : IPostAdapter
|
||||
.ForMember(x => x.Configuration, x => x.MapFrom(src => JsonSerializer.Serialize(src.ConfigurationModel, JsonSerializerOptions)));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public PostOperationResponse GetList()
|
||||
@@ -44,15 +48,10 @@ public class PostAdapter : IPostAdapter
|
||||
{
|
||||
return PostOperationResponse.OK([.. _postBusinessLogicContract.GetAllPosts().Select(x => _mapper.Map<PostViewModel>(x))]);
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return PostOperationResponse.NotFound("The list is not initialized");
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -70,17 +69,17 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Data is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return PostOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -99,22 +98,22 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Data is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return PostOperationResponse.NotFound($"Not found element by data {data}");
|
||||
return PostOperationResponse.NotFound(string.Format(_localizer["AdapterMessageElementNotFoundException"], data));
|
||||
}
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return PostOperationResponse.BadRequest($"Element by data:{data} was deleted");
|
||||
return PostOperationResponse.NotFound(string.Format(_localizer["AdapterMessageElementDeletedException"], data));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -134,12 +133,12 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Data is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return PostOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -149,7 +148,7 @@ public class PostAdapter : IPostAdapter
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.BadRequest($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -169,17 +168,17 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Data is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return PostOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return PostOperationResponse.BadRequest($"Not found element by Id {postModel.Id}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], postModel.Id));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -189,12 +188,12 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return PostOperationResponse.BadRequest($"Element by id: {postModel.Id} was deleted");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementDeletedException"], postModel.Id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.BadRequest($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -213,27 +212,27 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Id is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return PostOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return PostOperationResponse.BadRequest($"Not found element by id: {id}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return PostOperationResponse.BadRequest($"Element by id: {id} was deleted");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementDeletedException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.BadRequest($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -252,22 +251,22 @@ public class PostAdapter : IPostAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return PostOperationResponse.BadRequest("Id is empty");
|
||||
return PostOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return PostOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return PostOperationResponse.BadRequest($"Not found element by id: {id}");
|
||||
return PostOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return PostOperationResponse.BadRequest($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return PostOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BindingModels;
|
||||
@@ -6,17 +7,23 @@ using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
|
||||
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class ProductAdapter : IProductAdapter
|
||||
internal class ProductAdapter : IProductAdapter
|
||||
{
|
||||
private readonly IProductBusinessLogicContract _productBusinessLogicContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
public ProductAdapter(IProductBusinessLogicContract productBusinessLogicContract, ILogger<ProductAdapter> logger)
|
||||
|
||||
public ProductAdapter(IProductBusinessLogicContract productBusinessLogicContract, IStringLocalizer<Messages> localizer, ILogger<ProductAdapter> logger)
|
||||
{
|
||||
_productBusinessLogicContract = productBusinessLogicContract;
|
||||
_logger = logger;
|
||||
@@ -27,6 +34,7 @@ public class ProductAdapter : IProductAdapter
|
||||
cfg.CreateMap<ProductHistoryDataModel, ProductHistoryViewModel>();
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public ProductOperationResponse GetList(bool includeDeleted)
|
||||
@@ -35,15 +43,10 @@ public class ProductAdapter : IProductAdapter
|
||||
{
|
||||
return ProductOperationResponse.OK([.._productBusinessLogicContract.GetAllProducts(!includeDeleted).Select(x => _mapper.Map<ProductViewModel>(x))]);
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return ProductOperationResponse.NotFound("The list is not initialized");
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -62,17 +65,12 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return ProductOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return ProductOperationResponse.NotFound("The list is not initialized");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -92,22 +90,22 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return ProductOperationResponse.BadRequest("Data is empty");
|
||||
return ProductOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return ProductOperationResponse.NotFound($"Not found element by data { data} ");
|
||||
return ProductOperationResponse.NotFound(string.Format(_localizer["AdapterMessageElementNotFoundException"], data));
|
||||
}
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return ProductOperationResponse.BadRequest($"Element by data: { data} was deleted");
|
||||
return ProductOperationResponse.NotFound(string.Format(_localizer["AdapterMessageElementDeletedException"], data));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -127,12 +125,12 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return ProductOperationResponse.BadRequest("Data is empty");
|
||||
return ProductOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return ProductOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -142,7 +140,7 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -162,17 +160,17 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return ProductOperationResponse.BadRequest("Data is empty");
|
||||
return ProductOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return ProductOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return ProductOperationResponse.BadRequest($"Not found element by Id { productModel.Id} ");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], productModel.Id));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -182,12 +180,12 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return ProductOperationResponse.BadRequest($"Element by id: { productModel.Id} was deleted");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementDeletedException"], productModel.Id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -207,27 +205,27 @@ public class ProductAdapter : IProductAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return ProductOperationResponse.BadRequest("Id is empty");
|
||||
return ProductOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return ProductOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return ProductOperationResponse.BadRequest($"Not found element by id: { id} ");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return ProductOperationResponse.BadRequest($"Element by id: { id} was deleted");
|
||||
return ProductOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementDeletedException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ProductOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return ProductOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class ReportAdapter : IReportAdapter
|
||||
internal class ReportAdapter : IReportAdapter
|
||||
{
|
||||
private readonly IReportContract _reportContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public ReportAdapter(IReportContract reportContract, ILogger logger)
|
||||
public ReportAdapter(IReportContract reportContract, IStringLocalizer<Messages> localizer, ILogger logger)
|
||||
{
|
||||
_reportContract = reportContract;
|
||||
_logger = logger;
|
||||
@@ -30,6 +34,7 @@ public class ReportAdapter : IReportAdapter
|
||||
cfg.CreateMap<WorkerSalaryByPeriodDataModel, WorkerSalaryByPeriodViewModel>();
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public async Task<ReportOperationResponse> CreateDocumentProductsHistoryAsync(CancellationToken ct)
|
||||
@@ -41,12 +46,12 @@ public class ReportAdapter : IReportAdapter
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -60,23 +65,23 @@ public class ReportAdapter : IReportAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return SendStream(await _reportContract.CreateDocumentSalesByPeriodAsync(dateStart, dateFinish, ct),
|
||||
return SendStream(await _reportContract.CreateDocumentSalesByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct),
|
||||
"sales.xslx");
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return ReportOperationResponse.BadRequest($"Incorrect dates: {ex.Message}");
|
||||
return ReportOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -95,12 +100,12 @@ public class ReportAdapter : IReportAdapter
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -114,23 +119,23 @@ public class ReportAdapter : IReportAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReportOperationResponse.OK((await _reportContract.GetDataSaleByPeriodAsync(dateStart, dateFinish, ct)).Select(x =>
|
||||
return ReportOperationResponse.OK((await _reportContract.GetDataSaleByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct)).Select(x =>
|
||||
_mapper.Map<SaleViewModel>(x)).ToList());
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return ReportOperationResponse.BadRequest($"Incorrect dates: {ex.Message}");
|
||||
return ReportOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -144,22 +149,22 @@ public class ReportAdapter : IReportAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return ReportOperationResponse.OK((await _reportContract.GetDataSalaryByPeriodAsync(dateStart, dateFinish, ct)).Select(x => _mapper.Map<WorkerSalaryByPeriodViewModel>(x)).ToList());
|
||||
return ReportOperationResponse.OK((await _reportContract.GetDataSalaryByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct)).Select(x => _mapper.Map<WorkerSalaryByPeriodViewModel>(x)).ToList());
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return ReportOperationResponse.BadRequest($"Incorrect dates: {ex.Message}");
|
||||
return ReportOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -172,22 +177,22 @@ public class ReportAdapter : IReportAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return SendStream(await _reportContract.CreateDocumentSalaryByPeriodAsync(dateStart, dateFinish, ct), "salary.pdf");
|
||||
return SendStream(await _reportContract.CreateDocumentSalaryByPeriodAsync(dateStart.ToUniversalTime(), dateFinish.ToUniversalTime(), ct), "salary.pdf");
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return ReportOperationResponse.BadRequest($"Incorrect dates: {ex.Message} ");
|
||||
return ReportOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (InvalidOperationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "InvalidOperationException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageInvalidOperationException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return ReportOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return ReportOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,59 +1,59 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class SalaryAdapter : ISalaryAdapter
|
||||
internal class SalaryAdapter : ISalaryAdapter
|
||||
{
|
||||
private readonly ISalaryBusinessLogicContract _salaryBusinessLogicContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public SalaryAdapter(ISalaryBusinessLogicContract salaryBusinessLogicContract, ILogger<SalaryAdapter> logger)
|
||||
public SalaryAdapter(ISalaryBusinessLogicContract salaryBusinessLogicContract, IStringLocalizer<Messages> localizer, ILogger<SalaryAdapter> logger)
|
||||
{
|
||||
_salaryBusinessLogicContract = salaryBusinessLogicContract;
|
||||
_logger = logger;
|
||||
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<SalaryDataModel, SalaryViewModel>();
|
||||
cfg.CreateMap<SalaryDataModel, SalaryViewModel>().ForMember(x => x.SalaryDate, x => x.MapFrom(src => src.SalaryDate.ToLocalTime()));
|
||||
});
|
||||
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public SalaryOperationResponse GetListByPeriod(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
return SalaryOperationResponse.OK([.. _salaryBusinessLogicContract.GetAllSalariesByPeriod(fromDate, toDate).Select(x => _mapper.Map<SalaryViewModel>(x))]);
|
||||
return SalaryOperationResponse.OK([.. _salaryBusinessLogicContract.GetAllSalariesByPeriod(fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<SalaryViewModel>(x))]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SalaryOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return SalaryOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return SalaryOperationResponse.BadRequest($"Incorrect dates: {ex.Message}");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SalaryOperationResponse.NotFound("The list is not initialized");
|
||||
return SalaryOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SalaryOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return SalaryOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -66,27 +66,22 @@ public class SalaryAdapter : ISalaryAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return SalaryOperationResponse.OK([.. _salaryBusinessLogicContract.GetAllSalariesByPeriodByWorker(fromDate, toDate, workerId).Select(x => _mapper.Map<SalaryViewModel>(x))]);
|
||||
return SalaryOperationResponse.OK([.. _salaryBusinessLogicContract.GetAllSalariesByPeriodByWorker(fromDate.ToUniversalTime(), toDate.ToUniversalTime(), workerId).Select(x => _mapper.Map<SalaryViewModel>(x))]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SalaryOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message}");
|
||||
return SalaryOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return SalaryOperationResponse.BadRequest($"Incorrect dates: {ex.Message}");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SalaryOperationResponse.NotFound("The list is not initialized");
|
||||
return SalaryOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SalaryOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return SalaryOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -99,18 +94,13 @@ public class SalaryAdapter : ISalaryAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
_salaryBusinessLogicContract.CalculateSalaryByMounth(date);
|
||||
_salaryBusinessLogicContract.CalculateSalaryByMounth(date.ToUniversalTime());
|
||||
return SalaryOperationResponse.NoContent();
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SalaryOperationResponse.NotFound("The list is not initialized");
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SalaryOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message}");
|
||||
return SalaryOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,23 +1,27 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BindingModels;
|
||||
using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class SaleAdapter : ISaleAdapter
|
||||
internal class SaleAdapter : ISaleAdapter
|
||||
{
|
||||
private readonly ISaleBusinessLogicContract _saleBusinessLogicContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public SaleAdapter(ISaleBusinessLogicContract saleBusinessLogicContract, ILogger<SaleAdapter> logger)
|
||||
public SaleAdapter(ISaleBusinessLogicContract saleBusinessLogicContract, IStringLocalizer<Messages> localizer, ILogger<SaleAdapter> logger)
|
||||
{
|
||||
_saleBusinessLogicContract = saleBusinessLogicContract;
|
||||
_logger = logger;
|
||||
@@ -29,28 +33,24 @@ public class SaleAdapter : ISaleAdapter
|
||||
cfg.CreateMap<ProductForSaleDataModel, ProductForSaleViewModel>();
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public SaleOperationResponse GetList(DateTime fromDate, DateTime toDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByPeriod(fromDate, toDate).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByPeriod(fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect dates: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SaleOperationResponse.NotFound("The list is not initialized");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -63,27 +63,22 @@ public class SaleAdapter : ISaleAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByWorkerByPeriod(id, fromDate, toDate).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByWorkerByPeriod(id, fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect dates: { ex.Message} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SaleOperationResponse.NotFound("The list is not initialized");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -97,27 +92,22 @@ public class SaleAdapter : ISaleAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByProductByPeriod(id, fromDate, toDate).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
return SaleOperationResponse.OK([.._saleBusinessLogicContract.GetAllSalesByProductByPeriod(id, fromDate.ToUniversalTime(), toDate.ToUniversalTime()).Select(x => _mapper.Map<SaleViewModel>(x))]);
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect dates: { ex.Message} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return SaleOperationResponse.NotFound("The list is not initialized");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -135,22 +125,22 @@ public class SaleAdapter : ISaleAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return SaleOperationResponse.BadRequest("Data is empty");
|
||||
return SaleOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect data transmitted: {ex.Message} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return SaleOperationResponse.NotFound($"Not found element by data {id} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.InternalServerError($"Error while working with data storage: {ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -170,17 +160,17 @@ public class SaleAdapter : ISaleAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return SaleOperationResponse.BadRequest("Data is empty");
|
||||
return SaleOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -199,27 +189,27 @@ public class SaleAdapter : ISaleAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return SaleOperationResponse.BadRequest("Id is empty");
|
||||
return SaleOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return SaleOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return SaleOperationResponse.BadRequest($"Not found element by id: { id} ");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (ElementDeletedException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementDeletedException");
|
||||
return SaleOperationResponse.BadRequest($"Element by id: {id} was deleted");
|
||||
return SaleOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementDeletedException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return SaleOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return SaleOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using North_Bridge_Contract.AdapterContracts;
|
||||
using North_Bridge_Contract.AdapterContracts.OperationResponses;
|
||||
using North_Bridge_Contract.BindingModels;
|
||||
@@ -6,28 +7,33 @@ using North_Bridge_Contract.BusinessLogicsContracts;
|
||||
using North_Bridge_Contract.DataModels;
|
||||
using North_Bridge_Contract.Exceptions;
|
||||
using North_Bridge_Contract.Extentions;
|
||||
using North_Bridge_Contract.Resources;
|
||||
using North_Bridge_Contract.ViewModels;
|
||||
|
||||
namespace North_Bridge_WebApi.Adapters;
|
||||
|
||||
public class WorkerAdapter : IWorkerAdapter
|
||||
internal class WorkerAdapter : IWorkerAdapter
|
||||
{
|
||||
private readonly IWorkerBusinessLogicContract _workerBusinessLogicContract;
|
||||
|
||||
private readonly IStringLocalizer<Messages> _localizer;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly Mapper _mapper;
|
||||
|
||||
public WorkerAdapter(IWorkerBusinessLogicContract workerBusinessLogicContract, ILogger<WorkerAdapter> logger)
|
||||
public WorkerAdapter(IWorkerBusinessLogicContract workerBusinessLogicContract, IStringLocalizer<Messages> localizer, ILogger<WorkerAdapter> logger)
|
||||
{
|
||||
_workerBusinessLogicContract = workerBusinessLogicContract;
|
||||
_logger = logger;
|
||||
var config = new MapperConfiguration(cfg =>
|
||||
{
|
||||
cfg.CreateMap<WorkerBindingModel, WorkerDataModel>();
|
||||
cfg.CreateMap<WorkerDataModel, WorkerViewModel>();
|
||||
cfg.CreateMap<WorkerDataModel, WorkerViewModel>().ForMember(x => x.BirthDate, x => x.MapFrom(src => src.BirthDate.ToLocalTime()))
|
||||
.ForMember(x => x.EmploymentDate, x => x.MapFrom(src => src.EmploymentDate.ToLocalTime()));
|
||||
});
|
||||
_mapper = new Mapper(config);
|
||||
_localizer = localizer;
|
||||
}
|
||||
|
||||
public WorkerOperationResponse GetList(bool includeDeleted)
|
||||
@@ -36,15 +42,10 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
{
|
||||
return WorkerOperationResponse.OK([.. _workerBusinessLogicContract.GetAllWorkers(!includeDeleted).Select(x => _mapper.Map<WorkerViewModel>(x))]);
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return WorkerOperationResponse.NotFound("The list is not initialized");
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -63,17 +64,12 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return WorkerOperationResponse.NotFound("The list is not initialized");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -88,22 +84,17 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return WorkerOperationResponse.OK([.. _workerBusinessLogicContract.GetAllWorkersByBirthDate(fromDate, toDate, !includeDeleted).Select(x => _mapper.Map<WorkerViewModel>(x))]);
|
||||
return WorkerOperationResponse.OK([.. _workerBusinessLogicContract.GetAllWorkersByBirthDate(fromDate.ToUniversalTime(), toDate.ToUniversalTime(), !includeDeleted).Select(x => _mapper.Map<WorkerViewModel>(x))]);
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect dates: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return WorkerOperationResponse.NotFound("The list is not initialized");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -118,22 +109,17 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
{
|
||||
try
|
||||
{
|
||||
return WorkerOperationResponse.OK([.. _workerBusinessLogicContract.GetAllWorkersByEmploymentDate(fromDate, toDate, !includeDeleted).Select(x => _mapper.Map<WorkerViewModel>(x))]);
|
||||
return WorkerOperationResponse.OK([.. _workerBusinessLogicContract.GetAllWorkersByEmploymentDate(fromDate.ToUniversalTime(), toDate.ToUniversalTime(), !includeDeleted).Select(x => _mapper.Map<WorkerViewModel>(x))]);
|
||||
}
|
||||
catch (IncorrectDatesException ex)
|
||||
{
|
||||
_logger.LogError(ex, "IncorrectDatesException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect dates: { ex.Message} ");
|
||||
}
|
||||
catch (NullListException)
|
||||
{
|
||||
_logger.LogError("NullListException");
|
||||
return WorkerOperationResponse.NotFound("The list is not initialized");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageIncorrectDatesException"], ex.Message));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -152,22 +138,22 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return WorkerOperationResponse.BadRequest("Data is empty");
|
||||
return WorkerOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return WorkerOperationResponse.NotFound($"Not found element by data { data} ");
|
||||
return WorkerOperationResponse.NotFound(string.Format(_localizer["AdapterMessageElementNotFoundException"], data));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.InternalServerError($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -188,12 +174,12 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return WorkerOperationResponse.BadRequest("Data is empty");
|
||||
return WorkerOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -203,7 +189,7 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -224,17 +210,17 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return WorkerOperationResponse.BadRequest("Data is empty");
|
||||
return WorkerOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return WorkerOperationResponse.BadRequest($"Not found element by Id { workerModel.Id} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], workerModel.Id));
|
||||
}
|
||||
catch (ElementExistsException ex)
|
||||
{
|
||||
@@ -244,7 +230,7 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -264,22 +250,22 @@ public class WorkerAdapter : IWorkerAdapter
|
||||
catch (ArgumentNullException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ArgumentNullException");
|
||||
return WorkerOperationResponse.BadRequest("Id is empty");
|
||||
return WorkerOperationResponse.BadRequest(_localizer["AdapterMessageEmptyDate"]);
|
||||
}
|
||||
catch (ValidationException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ValidationException");
|
||||
return WorkerOperationResponse.BadRequest($"Incorrect data transmitted: { ex.Message} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageValidationException"], ex.Message));
|
||||
}
|
||||
catch (ElementNotFoundException ex)
|
||||
{
|
||||
_logger.LogError(ex, "ElementNotFoundException");
|
||||
return WorkerOperationResponse.BadRequest($"Not found element by id: { id} ");
|
||||
return WorkerOperationResponse.BadRequest(string.Format(_localizer["AdapterMessageElementNotFoundException"], id));
|
||||
}
|
||||
catch (StorageException ex)
|
||||
{
|
||||
_logger.LogError(ex, "StorageException");
|
||||
return WorkerOperationResponse.BadRequest($"Error while working with data storage: { ex.InnerException!.Message} ");
|
||||
return WorkerOperationResponse.InternalServerError(string.Format(_localizer["AdapterMessageStorageException"], ex.InnerException!.Message));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||
using Microsoft.AspNetCore.Localization;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using North_Bridge_BusinessLogics.Implementations;
|
||||
using North_Bridge_BusinessLogics.OfficePackage;
|
||||
@@ -13,6 +15,7 @@ using North_Bridge_WebApi;
|
||||
using North_Bridge_WebApi.Adapters;
|
||||
using North_Bridge_WebApi.Infrastructure;
|
||||
using Serilog;
|
||||
using System.Globalization;
|
||||
using System.IdentityModel.Tokens.Jwt;
|
||||
using System.Security.Claims;
|
||||
|
||||
@@ -52,6 +55,22 @@ options.TokenValidationParameters = new TokenValidationParameters
|
||||
};
|
||||
});
|
||||
|
||||
builder.Services.AddLocalization();
|
||||
builder.Services.Configure<RequestLocalizationOptions>(
|
||||
options =>
|
||||
{
|
||||
var supportedCultures = new List<CultureInfo>
|
||||
{
|
||||
new("de-DE"),
|
||||
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<IPostBusinessLogicContract, PostBusinessLogicContract>();
|
||||
@@ -134,4 +153,11 @@ app.Map("/login/{username}", (string username) =>
|
||||
|
||||
app.MapControllers();
|
||||
|
||||
var localizeOptions =
|
||||
app.Services.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
if (localizeOptions is not null)
|
||||
{
|
||||
app.UseRequestLocalization(localizeOptions.Value);
|
||||
}
|
||||
|
||||
app.Run();
|
||||
Reference in New Issue
Block a user