forked from slavaxom9k/PIBD-23_Fomichev_V.S._MagicCarpet
правки правки....
This commit is contained in:
@@ -16,17 +16,17 @@ namespace MagicCarpetBusinessLogic.Implementations;
|
|||||||
|
|
||||||
public class AgencyBusinessLogicContract(IAgencyStorageContract agencyStorageContract, ILogger logger) : IAgencyBusinessLogicContract
|
public class AgencyBusinessLogicContract(IAgencyStorageContract agencyStorageContract, ILogger logger) : IAgencyBusinessLogicContract
|
||||||
{
|
{
|
||||||
private readonly IAgencyStorageContract _AgencyStorageContract = agencyStorageContract;
|
private readonly IAgencyStorageContract _agencyStorageContract = agencyStorageContract;
|
||||||
private readonly ILogger _logger = logger;
|
private readonly ILogger _logger = logger;
|
||||||
public List<AgencyDataModel> GetAllComponents()
|
public List<AgencyDataModel> GetAllAgencies()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("GetAllComponents");
|
_logger.LogInformation("GetAllTours");
|
||||||
return _AgencyStorageContract.GetList() ?? throw new NullListException();
|
return _agencyStorageContract.GetList() ?? throw new NullListException();
|
||||||
|
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public AgencyDataModel GetTourByData(string data)
|
public AgencyDataModel GetAgencyByData(string data)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Get element by data: {data}", data);
|
_logger.LogInformation("Get element by data: {data}", data);
|
||||||
if (data.IsEmpty())
|
if (data.IsEmpty())
|
||||||
@@ -37,28 +37,28 @@ public class AgencyBusinessLogicContract(IAgencyStorageContract agencyStorageCon
|
|||||||
{
|
{
|
||||||
throw new ElementNotFoundException(data);
|
throw new ElementNotFoundException(data);
|
||||||
}
|
}
|
||||||
return _AgencyStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
return _agencyStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||||
|
|
||||||
return new("", TourType.None, 0, []);
|
return new("", TourType.None, 0, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertTour(AgencyDataModel AgencyDataModel)
|
public void InsertAgency(AgencyDataModel AgencyDataModel)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(AgencyDataModel));
|
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(AgencyDataModel));
|
||||||
ArgumentNullException.ThrowIfNull(AgencyDataModel);
|
ArgumentNullException.ThrowIfNull(AgencyDataModel);
|
||||||
AgencyDataModel.Validate();
|
AgencyDataModel.Validate();
|
||||||
_AgencyStorageContract.AddElement(AgencyDataModel);
|
_agencyStorageContract.AddElement(AgencyDataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTour(AgencyDataModel AgencyDataModel)
|
public void UpdateAgency(AgencyDataModel AgencyDataModel)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(AgencyDataModel));
|
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(AgencyDataModel));
|
||||||
ArgumentNullException.ThrowIfNull(AgencyDataModel);
|
ArgumentNullException.ThrowIfNull(AgencyDataModel);
|
||||||
AgencyDataModel.Validate();
|
AgencyDataModel.Validate();
|
||||||
_AgencyStorageContract.UpdElement(AgencyDataModel);
|
_agencyStorageContract.UpdElement(AgencyDataModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DeleteTour(string id)
|
public void DeleteAgency(string id)
|
||||||
{
|
{
|
||||||
logger.LogInformation("Delete by id: {id}", id);
|
logger.LogInformation("Delete by id: {id}", id);
|
||||||
if (id.IsEmpty())
|
if (id.IsEmpty())
|
||||||
@@ -69,6 +69,6 @@ public class AgencyBusinessLogicContract(IAgencyStorageContract agencyStorageCon
|
|||||||
{
|
{
|
||||||
throw new ValidationException("Id is not a unique identifier");
|
throw new ValidationException("Id is not a unique identifier");
|
||||||
}
|
}
|
||||||
_AgencyStorageContract.DelElement(id);
|
_agencyStorageContract.DelElement(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,20 +16,39 @@ namespace MagicCarpetBusinessLogic.Implementations;
|
|||||||
|
|
||||||
public class SuppliesBusinessLogicContract(ISuppliesStorageContract suppliesStorageContract, ILogger logger) : ISuppliesBusinessLogicContract
|
public class SuppliesBusinessLogicContract(ISuppliesStorageContract suppliesStorageContract, ILogger logger) : ISuppliesBusinessLogicContract
|
||||||
{
|
{
|
||||||
private readonly ISuppliesStorageContract _suppliesStorageContract = suppliesStorageContract;
|
|
||||||
private readonly ILogger _logger = logger;
|
private readonly ILogger _logger = logger;
|
||||||
|
private readonly ISuppliesStorageContract _supplyStorageContract = suppliesStorageContract;
|
||||||
public List<SuppliesDataModel> GetAllTours()
|
public List<SuppliesDataModel> GetAllSuppliesByPeriod(DateTime fromDate, DateTime toDate)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("GetAllTours");
|
_logger.LogInformation("GetAllSupplies params: {fromDate}, {toDate}", fromDate, toDate);
|
||||||
return _suppliesStorageContract.GetList() ?? throw new NullListException();
|
if (fromDate.IsDateNotOlder(toDate))
|
||||||
|
{
|
||||||
return [];
|
throw new IncorrectDatesException(fromDate, toDate);
|
||||||
|
}
|
||||||
|
return _supplyStorageContract.GetList(fromDate, toDate) ?? throw new NullListException();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SuppliesDataModel GetTourByData(string data)
|
public List<SuppliesDataModel> GetAllSuppliesByCocktailByPeriod(string tourId, DateTime fromDate, DateTime toDate)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Get element by data: {data}", data);
|
_logger.LogInformation("GetAllSupplies params: {cocktailId}, {fromDate}, {toDate}", tourId, fromDate, toDate);
|
||||||
|
if (fromDate.IsDateNotOlder(toDate))
|
||||||
|
{
|
||||||
|
throw new IncorrectDatesException(fromDate, toDate);
|
||||||
|
}
|
||||||
|
if (tourId.IsEmpty())
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(tourId));
|
||||||
|
}
|
||||||
|
if (!tourId.IsGuid())
|
||||||
|
{
|
||||||
|
throw new ValidationException("The value in the field tourId is not a unique identifier.");
|
||||||
|
}
|
||||||
|
return _supplyStorageContract.GetList(fromDate, toDate, tourId: tourId) ?? throw new NullListException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SuppliesDataModel GetSupplyByData(string data)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Get supply by data: {data}", data);
|
||||||
if (data.IsEmpty())
|
if (data.IsEmpty())
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(data));
|
throw new ArgumentNullException(nameof(data));
|
||||||
@@ -38,25 +57,22 @@ public class SuppliesBusinessLogicContract(ISuppliesStorageContract suppliesStor
|
|||||||
{
|
{
|
||||||
throw new ElementNotFoundException(data);
|
throw new ElementNotFoundException(data);
|
||||||
}
|
}
|
||||||
return _suppliesStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
return _supplyStorageContract.GetElementById(data) ?? throw new ElementNotFoundException(data);
|
||||||
|
|
||||||
return new("", TourType.None, DateTime.UtcNow, 0, []);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InsertTour(SuppliesDataModel suppliesDataModel)
|
public void InsertSupply(SuppliesDataModel supplyDataModel)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(suppliesDataModel));
|
_logger.LogInformation("New data: {json}", JsonSerializer.Serialize(supplyDataModel));
|
||||||
ArgumentNullException.ThrowIfNull(suppliesDataModel);
|
ArgumentNullException.ThrowIfNull(supplyDataModel);
|
||||||
suppliesDataModel.Validate();
|
supplyDataModel.Validate();
|
||||||
_suppliesStorageContract.AddElement(suppliesDataModel);
|
_supplyStorageContract.AddElement(supplyDataModel);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateTour(SuppliesDataModel suppliesDataModel)
|
public void UpdateSupply(SuppliesDataModel supplyDataModel)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(suppliesDataModel));
|
_logger.LogInformation("Update data: {json}", JsonSerializer.Serialize(supplyDataModel));
|
||||||
ArgumentNullException.ThrowIfNull(suppliesDataModel);
|
ArgumentNullException.ThrowIfNull(supplyDataModel);
|
||||||
suppliesDataModel.Validate();
|
supplyDataModel.Validate();
|
||||||
_suppliesStorageContract.UpdElement(suppliesDataModel);
|
_supplyStorageContract.UpdElement(supplyDataModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ namespace MagicCarpetContracts.BusinessLogicContracts;
|
|||||||
|
|
||||||
public interface IAgencyBusinessLogicContract
|
public interface IAgencyBusinessLogicContract
|
||||||
{
|
{
|
||||||
List<AgencyDataModel> GetAllTours();
|
List<AgencyDataModel> GetAllAgencies();
|
||||||
AgencyDataModel GetTourByData(string data);
|
AgencyDataModel GetAgencyByData(string data);
|
||||||
void InsertTour(AgencyDataModel agencyDataModel);
|
void InsertAgency(AgencyDataModel agencyDataModel);
|
||||||
void UpdateTour(AgencyDataModel agencyDataModel);
|
void UpdateAgency(AgencyDataModel agencyDataModel);
|
||||||
void DeleteTour(string id);
|
void DeleteAgency(string id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,8 +9,13 @@ namespace MagicCarpetContracts.BusinessLogicContracts;
|
|||||||
|
|
||||||
public interface ISuppliesBusinessLogicContract
|
public interface ISuppliesBusinessLogicContract
|
||||||
{
|
{
|
||||||
List<SuppliesDataModel> GetAllTours();
|
List<SuppliesDataModel> GetAllSuppliesByPeriod(DateTime fromDate, DateTime toDate);
|
||||||
SuppliesDataModel GetTourByData(string data);
|
|
||||||
void InsertTour(SuppliesDataModel componentDataModel);
|
List<SuppliesDataModel> GetAllSuppliesByCocktailByPeriod(string tourId, DateTime fromDate, DateTime toDate);
|
||||||
void UpdateTour(SuppliesDataModel componentDataModel);
|
|
||||||
|
SuppliesDataModel GetSupplyByData(string data);
|
||||||
|
|
||||||
|
void InsertSupply(SuppliesDataModel supplyDataModel);
|
||||||
|
|
||||||
|
void UpdateSupply(SuppliesDataModel supplyDataModel);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,8 @@ namespace MagicCarpetContracts.StoragesContracts;
|
|||||||
public interface IAgencyStorageContract
|
public interface IAgencyStorageContract
|
||||||
{
|
{
|
||||||
List<AgencyDataModel> GetList();
|
List<AgencyDataModel> GetList();
|
||||||
AgencyDataModel GetElementById(string id);
|
AgencyDataModel? GetElementById(string id);
|
||||||
|
AgencyDataModel? GetElementByName(string name);
|
||||||
void AddElement(AgencyDataModel agencyDataModel);
|
void AddElement(AgencyDataModel agencyDataModel);
|
||||||
void UpdElement(AgencyDataModel agencyDataModel);
|
void UpdElement(AgencyDataModel agencyDataModel);
|
||||||
void DelElement(string id);
|
void DelElement(string id);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace MagicCarpetContracts.StoragesContracts;
|
|||||||
|
|
||||||
public interface ISuppliesStorageContract
|
public interface ISuppliesStorageContract
|
||||||
{
|
{
|
||||||
List<SuppliesDataModel> GetList(DateTime? startDate = null);
|
List<SuppliesDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string? tourId = null);
|
||||||
SuppliesDataModel GetElementById(string id);
|
SuppliesDataModel GetElementById(string id);
|
||||||
void AddElement(SuppliesDataModel suppliesDataModel);
|
void AddElement(SuppliesDataModel suppliesDataModel);
|
||||||
void UpdElement(SuppliesDataModel suppliesDataModel);
|
void UpdElement(SuppliesDataModel suppliesDataModel);
|
||||||
|
|||||||
Reference in New Issue
Block a user