add Assembly, Component, Product contracts

This commit is contained in:
ShabOl 2024-04-23 22:29:39 +04:00
parent 1f59b3f931
commit 8a003df724
15 changed files with 275 additions and 0 deletions

View File

@ -0,0 +1,19 @@
using ComputerShopDataModels.Models;
namespace ComputerShopContracts.BindingModels
{
public class AssemblyBindingModel : IAssemblyModel
{
public int Id { get; set; }
public int UserId { get; set; }
public string AssemblyName { get; set; } = string.Empty;
public double Cost { get; set; }
public string Category { get; set; } = string.Empty;
public Dictionary<int, (IComponentModel, int)> AssemblyComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,15 @@
using ComputerShopDataModels.Models;
namespace ComputerShopContracts.BindingModels
{
public class ComponentBindingModel : IComponentModel
{
public int Id { get; set; }
public int UserId { get; set; }
public string ComponentName { get; set; } = string.Empty;
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using ComputerShopDataModels.Models;
namespace ComputerShopContracts.BindingModels
{
public class ProductBindingModel : IProductModel
{
public int Id { get; set; }
public int UserId { get; set; }
public string ProductName { get; set; } = string.Empty;
public double Cost { get; set; }
public int Warranty { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
public int? ShipmentId { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.BusinessLogicContracts
{
public interface IAssemblyLogic
{
List<AssemblyViewModel>? ReadList(AssemblySearchModel? Model);
AssemblyViewModel? ReadElement(AssemblySearchModel Model);
bool Create(AssemblyBindingModel Model);
bool Update(AssemblyBindingModel Model);
bool Delete(AssemblyBindingModel Model);
}
}

View File

@ -0,0 +1,19 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.BusinessLogicContracts
{
public interface IComponentLogic
{
List<ComponentViewModel>? ReadList(ComponentSearchModel? Model);
ComponentViewModel? ReadElement(ComponentSearchModel Model);
bool Create(ComponentBindingModel Model);
bool Update(ComponentBindingModel Model);
bool Delete(ComponentBindingModel Model);
}
}

View File

@ -0,0 +1,19 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.BusinessLogicContracts
{
public interface IProductLogic
{
List<ProductViewModel>? ReadList(ProductSearchModel? Model);
ProductViewModel? ReadElement(ProductSearchModel Model);
bool Create(ProductBindingModel Model);
bool Update(ProductBindingModel Model);
bool Delete(ProductBindingModel Model);
}
}

View File

@ -0,0 +1,11 @@
namespace ComputerShopContracts.SearchModels
{
public class AssemblySearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public string? Category { get; set; }
}
}

View File

@ -0,0 +1,9 @@
namespace ComputerShopContracts.SearchModels
{
public class ComponentSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
}
}

View File

@ -0,0 +1,11 @@
namespace ComputerShopContracts.SearchModels
{
public class ProductSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public int? ShipmentId { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.StorageContracts
{
public interface IAssemblyStorage
{
List<AssemblyViewModel> GetFullList();
List<AssemblyViewModel> GetFilteredList(AssemblySearchModel Model);
AssemblyViewModel? GetElement(AssemblySearchModel Model);
AssemblyViewModel? Insert(AssemblyBindingModel Model);
AssemblyViewModel? Update(AssemblyBindingModel Model);
AssemblyViewModel? Delete(AssemblyBindingModel Model);
}
}

View File

@ -0,0 +1,21 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.StorageContracts
{
public interface IComponentStorage
{
List<ComponentViewModel> GetFullList();
List<ComponentViewModel> GetFilteredList(ComponentSearchModel Model);
ComponentViewModel? GetElement(ComponentSearchModel Model);
ComponentViewModel? Insert(ComponentBindingModel Model);
ComponentViewModel? Update(ComponentBindingModel Model);
ComponentViewModel? Delete(ComponentBindingModel Model);
}
}

View File

@ -0,0 +1,21 @@
using ComputerShopContracts.BindingModels;
using ComputerShopContracts.SearchModels;
using ComputerShopContracts.ViewModels;
namespace ComputerShopContracts.StorageContracts
{
public interface IProductStorage
{
List<ProductViewModel> GetFullList();
List<ProductViewModel> GetFilteredList(ProductSearchModel Model);
ProductViewModel? GetElement(ProductSearchModel Model);
ProductViewModel? Insert(ProductBindingModel Model);
ProductViewModel? Update(ProductBindingModel Model);
ProductViewModel? Delete(ProductBindingModel Model);
}
}

View File

@ -0,0 +1,23 @@
using ComputerShopDataModels.Models;
using System.ComponentModel;
namespace ComputerShopContracts.ViewModels
{
public class AssemblyViewModel : IAssemblyModel
{
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Название сборки")]
public string AssemblyName { get; set; } = string.Empty;
[DisplayName("Стоимость")]
public double Cost { get; set; }
[DisplayName("Категория")]
public string Category { get; set; } = string.Empty;
public Dictionary<int, (IComponentModel, int)> AssemblyComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,18 @@
using ComputerShopDataModels.Models;
using System.ComponentModel;
namespace ComputerShopContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
public int UserId { get; }
[DisplayName("Название комплектующей")]
public string ComponentName { get; } = string.Empty;
[DisplayName("Стоимость")]
public double Cost { get; }
}
}

View File

@ -0,0 +1,28 @@
using ComputerShopDataModels.Models;
using System.ComponentModel;
namespace ComputerShopContracts.ViewModels
{
public class ProductViewModel : IProductModel
{
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Название товара")]
public string ProductName { get; set; } = string.Empty;
[DisplayName("Стоимость")]
public double Cost { get; set; }
[DisplayName("Гарантия (мес.)")]
public int Warranty { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
public int? ShipmentId { get; set; }
[DisplayName("Поставщик")]
public string ProviderName { get; set; } = string.Empty;
}
}