Контракты и "реализация"

This commit is contained in:
RozhVan 2025-02-18 20:28:00 +04:00
parent f5cfdb9ebc
commit 5f93466956
19 changed files with 411 additions and 0 deletions

View File

@ -0,0 +1,39 @@
using Microsoft.Extensions.Logging;
using SeniorPomidorContracts.BuisnessLogicsContracts;
using SeniorPomidorContracts.DataModels;
using SeniorPomidorContracts.StoragesContracts;
namespace SeniorPomidorBuisnessLogic.Implementations;
public class HarvestBuisnessLogicContract(IHarvestStorageContract harvestStorageContract, ILogger logger) : IHarvestBuisnessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IHarvestStorageContract _harvestStorageContract = harvestStorageContract;
public List<HarvestDataModel> GetAllHarvest()
{
return [];
}
public HarvestDataModel GetAllHarvestByAmount(int amount)
{
return new HarvestDataModel("", 1);
}
public void InsertHarvest(HarvestDataModel harvestDataModel)
{
}
public void RestoreHarvest(string id)
{
}
public void UpdateHarvest(HarvestDataModel harvestDataModel)
{
}
public void DeleteHarvest(string id)
{
}
}

View File

@ -0,0 +1,35 @@
using Microsoft.Extensions.Logging;
using SeniorPomidorContracts.BuisnessLogicsContracts;
using SeniorPomidorContracts.DataModels;
using SeniorPomidorContracts.StoragesContracts;
namespace SeniorPomidorBuisnessLogic.Implementations;
public class PTypeBuisnessLogicContract(IPTypeStorageContract pTypeStorageContract, ILogger logger) : IPTypeBuisnessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IPTypeStorageContract _pTypeStorageContract = pTypeStorageContract;
public List<ProductTypeDataModel> GetAllPTypes()
{
return [];
}
public List<ProductTypeDataModel> GetAllPTypesByName(string name)
{
return [];
}
public void InsertProduct(ProductTypeDataModel productTypeDataModel)
{
}
public void UpdateProduct(ProductTypeDataModel productTypeDataModel)
{
}
public void DeleteProduct(string id)
{
}
}

View File

@ -0,0 +1,44 @@
using Microsoft.Extensions.Logging;
using SeniorPomidorContracts.BuisnessLogicsContracts;
using SeniorPomidorContracts.DataModels;
using SeniorPomidorContracts.StoragesContracts;
namespace SeniorPomidorBuisnessLogic.Implementations;
public class ProductBuisnessLogicContract(IProductStorageContract productStorageContract, ILogger logger) : IProductBuisnessLogicContract
{
private readonly ILogger _logger = logger;
private readonly IProductStorageContract _productStorageContract = productStorageContract;
public List<ProductDataModel> GetAllProducts(bool onlyActive = true)
{
return [];
}
public List<ProductDataModel> GetAllProductsByManufacturer(bool onlyActive = true)
{
return [];
}
public ProductDataModel GetProductByData(string data)
{
return new ProductDataModel("", "", "", "", 1, true);
}
public List<ProductHistoryDataModel> GetProductHistoryByProduct(string productId)
{
return [];
}
public void InsertProduct(ProductDataModel productDataModel)
{
}
public void UpdateProduct(ProductDataModel productDataModel)
{
}
public void DeleteProduct(string id)
{
}
}

View File

@ -0,0 +1,39 @@
using Microsoft.Extensions.Logging;
using SeniorPomidorContracts.BuisnessLogicsContracts;
using SeniorPomidorContracts.DataModels;
using SeniorPomidorContracts.StoragesContracts;
namespace SeniorPomidorBuisnessLogic.Implementations;
public class SupplierBuisnessLogicContract(ISupplierStorageContract supplierStorageContract, ILogger logger) : ISupplierBuisnessLogicContract
{
private readonly ILogger _logger = logger;
private readonly ISupplierStorageContract _supplierStorageContract = supplierStorageContract;
public List<SupplierDataModel> GetAllSuppliers()
{
return [];
}
public List<SupplierDataModel> GetAllSuppliersByName(string name)
{
return [];
}
public SupplierDataModel GetSupplierByPhoneNumber(string phoneNumber)
{
return new SupplierDataModel("", "", "", 1);
}
public void InsertProduct(SupplierDataModel supplierDataModel)
{
}
public void UpdateProduct(SupplierDataModel supplierDataModel)
{
}
public void DeleteProduct(string id)
{
}
}

View File

@ -0,0 +1,41 @@
using Microsoft.Extensions.Logging;
using SeniorPomidorContracts.BuisnessLogicsContracts;
using SeniorPomidorContracts.DataModels;
using SeniorPomidorContracts.StoragesContracts;
namespace SeniorPomidorBuisnessLogic.Implementations;
public class SupplyBuisnessLogicContract(ISupplyStorageContract supplyStorageContract, ILogger logger) : ISupplyBuisnessLogicContract
{
private readonly ILogger _logger = logger;
private readonly ISupplyStorageContract _supplyStorageContract = supplyStorageContract;
public List<SupplyDataModel> GetAllSuppliesByPeriod(DateTime fromDate, DateTime toDate)
{
return [];
}
public List<SupplyDataModel> GetAllSuppliesByProductByPeriod(string productId, DateTime fromDate, DateTime toDate)
{
return [];
}
public List<SupplyDataModel> GetAllSuppliesBySuppliersByPeriod(string supplierId, DateTime fromDate, DateTime toDate)
{
return [];
}
public SupplyDataModel GetSupplyByData(string data)
{
return new SupplyDataModel("", "", 1, DateTime.Now, true, []);
}
public void InsertSupply(SupplyDataModel supplyDataModel)
{
}
public void CancelSupply(string id)
{
}
}

View File

@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SeniorPomidorContracts\SeniorPomidorContracts.csproj" />
</ItemGroup>
</Project>

View File

@ -7,6 +7,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeniorPomidorContracts", "S
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeniorPomidorTests", "SeniorPomidorTests\SeniorPomidorTests.csproj", "{6B124CD9-5257-4E62-B736-9C59CCAC19D4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SeniorPomidorBuisnessLogic", "SeniorPomidorBuisnessLogic\SeniorPomidorBuisnessLogic.csproj", "{77513FB6-F4DB-4B37-8773-B7342004B6D7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -21,6 +23,10 @@ Global
{6B124CD9-5257-4E62-B736-9C59CCAC19D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B124CD9-5257-4E62-B736-9C59CCAC19D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6B124CD9-5257-4E62-B736-9C59CCAC19D4}.Release|Any CPU.Build.0 = Release|Any CPU
{77513FB6-F4DB-4B37-8773-B7342004B6D7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{77513FB6-F4DB-4B37-8773-B7342004B6D7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{77513FB6-F4DB-4B37-8773-B7342004B6D7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{77513FB6-F4DB-4B37-8773-B7342004B6D7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

View File

@ -0,0 +1,18 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.BuisnessLogicsContracts;
public interface IHarvestBuisnessLogicContract
{
List<HarvestDataModel> GetAllHarvest();
HarvestDataModel? GetAllHarvestByAmount(int amount);
void InsertHarvest(HarvestDataModel harvestDataModel);
void UpdateHarvest(HarvestDataModel harvestDataModel);
void DeleteHarvest(string id);
void RestoreHarvest(string id);
}

View File

@ -0,0 +1,16 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.BuisnessLogicsContracts;
public interface IPTypeBuisnessLogicContract
{
List<ProductTypeDataModel> GetAllPTypes();
List<ProductTypeDataModel> GetAllPTypesByName(string name);
void InsertProduct(ProductTypeDataModel productTypeDataModel);
void UpdateProduct(ProductTypeDataModel productTypeDataModel);
void DeleteProduct(string id);
}

View File

@ -0,0 +1,20 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.BuisnessLogicsContracts;
public interface IProductBuisnessLogicContract
{
List<ProductDataModel> GetAllProducts(bool onlyActive = true);
List<ProductDataModel> GetAllProductsByManufacturer(bool onlyActive = true);
List<ProductHistoryDataModel> GetProductHistoryByProduct(string productId);
ProductDataModel GetProductByData(string data);
void InsertProduct(ProductDataModel productDataModel);
void UpdateProduct(ProductDataModel productDataModel);
void DeleteProduct(string id);
}

View File

@ -0,0 +1,18 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.BuisnessLogicsContracts;
public interface ISupplierBuisnessLogicContract
{
List<SupplierDataModel> GetAllSuppliers();
SupplierDataModel GetSupplierByPhoneNumber(string phoneNumber);
List<SupplierDataModel> GetAllSuppliersByName(string name);
void InsertProduct(SupplierDataModel supplierDataModel);
void UpdateProduct(SupplierDataModel supplierDataModel);
void DeleteProduct(string id);
}

View File

@ -0,0 +1,18 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.BuisnessLogicsContracts;
public interface ISupplyBuisnessLogicContract
{
List<SupplyDataModel> GetAllSuppliesByPeriod(DateTime fromDate, DateTime toDate);
List<SupplyDataModel> GetAllSuppliesBySuppliersByPeriod(string supplierId, DateTime fromDate, DateTime toDate);
List<SupplyDataModel> GetAllSuppliesByProductByPeriod(string productId, DateTime fromDate, DateTime toDate);
SupplyDataModel GetSupplyByData(string data);
void InsertSupply(SupplyDataModel supplyDataModel);
void CancelSupply(string id);
}

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,17 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.StoragesContracts;
public interface IHarvestStorageContract
{
List<HarvestDataModel> GetList();
HarvestDataModel? GetElementById(string id);
void AddElement(HarvestDataModel harvestDataModel);
void UpdElement(HarvestDataModel harvestDataModel);
void DelElement(string id);
}

View File

@ -0,0 +1,19 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.StoragesContracts;
public interface IPTypeStorageContract
{
List<ProductTypeDataModel> GetList();
ProductTypeDataModel? GetElementById(string id);
ProductTypeDataModel? GetElementByName(string name);
void AddElement(ProductTypeDataModel productTypeDataModel);
void UpdElement(ProductTypeDataModel productTypeDataModel);
void DelElement(string id);
}

View File

@ -0,0 +1,25 @@
using SeniorPomidorContracts.DataModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SeniorPomidorContracts.StoragesContracts;
public interface IProductStorageContract
{
List<ProductDataModel> GetList(bool onlyActive = true, string harvestId = null);
List<ProductHistoryDataModel> GetHistoryByProductId(string productId);
ProductDataModel? GetElementById(string id);
ProductDataModel? GetElementByName(string name);
void AddElement(ProductDataModel productDataModel);
void UpdElement(ProductDataModel productDataModel);
void DelElement(string id);
}

View File

@ -0,0 +1,20 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.StoragesContracts;
public interface ISupplierStorageContract
{
List<SupplierDataModel> GetList();
SupplierDataModel? GetElementById(string id);
SupplierDataModel? GetElementByPhoneNumber(string phoneNumber);
SupplierDataModel? GetElementByName(string name);
void AddElement(SupplierDataModel supplierDataModel);
void UpdElement(SupplierDataModel supplierDataModel);
void DelElement(string id);
}

View File

@ -0,0 +1,14 @@
using SeniorPomidorContracts.DataModels;
namespace SeniorPomidorContracts.StoragesContracts;
public interface ISupplyStorageContract
{
List<SupplyDataModel> GetList(DateTime? startDate = null, DateTime? endDate = null, string? supplierId = null, string? productId = null);
SupplyDataModel? GetElementById(string id);
void AddElement(SupplyDataModel supplyDataModel);
void DelElement(string id);
}

View File

@ -10,6 +10,7 @@
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="NUnit" Version="4.2.2" />
<PackageReference Include="NUnit.Analyzers" Version="4.4.0" />