Contracts +

This commit is contained in:
Алексей Тихоненков 2024-04-29 20:02:11 +04:00
parent e7dda79c87
commit 4ab214e540
34 changed files with 591 additions and 6 deletions

View File

@ -0,0 +1,21 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BindingModels
{
public class CardBindingModel : ICardModel
{
public int Id { get; set; }
public int UserId { get; set; }
public string CardName { get; set; } = string.Empty;
public Dictionary<int, (IDrinkModel, int)> DrinkCard { get; set; } = new();
}
}

View File

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

View File

@ -0,0 +1,18 @@
using DiningRoomDataModels.Models;
namespace DiningRoomContracts.BindingModels
{
public class DrinkBindingModel : IDrinkModel
{
public int Id { get; set; }
public int UserId { get; set; }
public string DrinkName { get; set; } = string.Empty;
public double Cost { get; set; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,25 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BindingModels
{
public class OrderBindingModel : IOrderModel
{
public int Id { get; set; }
public int UserId { get; set; }
public DateTime DateCreate { get; set; } = DateTime.Now;
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
public Dictionary<int, (IProductModel, int)> ProductOrder { get; set; } = new();
public Dictionary<int, (IDrinkModel, int)> DrinkOrder { get; set; } = new();
public double Sum { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using DiningRoomDataModels.Models;
namespace DiningRoomContracts.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 Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,22 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BindingModels
{
public class UserBindingModel : IUserModel
{
public int Id { get; set; }
public string Login { get; set; } = string.Empty;
public string Password { get; set; } = string.Empty;
public string Email { get; set; } = string.Empty;
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BusinessLogicContracts
{
public interface ICardLogic
{
List<CardViewModel>? ReadList(CardSearchModel? model);
CardViewModel? ReadElement(CardSearchModel model);
bool Create(CardBindingModel model);
bool Update(CardBindingModel model);
bool Delete(CardBindingModel model);
bool ConnectCardDrink(int cardId, int drinkId);
}
}

View File

@ -0,0 +1,19 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.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 DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.BusinessLogicContracts
{
public interface IDrinkLogic
{
List<DrinkViewModel>? ReadList(DrinkSearchModel? Model);
DrinkViewModel? ReadElement(DrinkSearchModel Model);
bool Create(DrinkBindingModel Model);
bool Update(DrinkBindingModel Model);
bool Delete(DrinkBindingModel Model);
}
}

View File

@ -0,0 +1,23 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BusinessLogicContracts
{
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool Create(OrderBindingModel model);
bool Update(OrderBindingModel model);
bool Delete(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);
bool DeliveryOrder(OrderBindingModel model);
}
}

View File

@ -0,0 +1,19 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.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,20 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.BusinessLogicContracts
{
public interface IUserLogic
{
List<UserViewModel>? ReadList(UserSearchModel? model);
UserViewModel? ReadElement(UserSearchModel model);
bool Create(UserBindingModel model);
bool Update(UserBindingModel model);
bool Delete(UserBindingModel model);
}
}

View File

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DiningRoomDataModels\DiningRoomDataModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,11 @@
namespace DiningRoomContracts.SearchModels
{
public class CardSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public string? Cardname { get; set; }
}
}

View File

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

View File

@ -0,0 +1,11 @@
namespace DiningRoomContracts.SearchModels
{
public class DrinkSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public string? DrinkName { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.SearchModels
{
public class OrderSearchModel
{
public int? Id { get; set; }
public int? UserId { get; set; }
public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; }
public OrderStatus? Status { get; set; }
public Dictionary<int, (IProductModel, int)> ProductOrder { get; set; } = new();
public Dictionary<int, (IDrinkModel, int)> DrinkOrder { get; set; } = new();
public double? Sum { get; set; }
}
}

View File

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

View File

@ -0,0 +1,20 @@
using DiningRoomDataModels.Enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.SearchModels
{
public class UserSearchModel
{
public int? Id { get; set; }
public string? Login { get; set; }
public string Password { get; set; }
public string? Email { get; set; }
public UserRole? Role { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.StorageContracts
{
public interface ICardStorage
{
List<CardViewModel> GetFullList();
List<CardViewModel> GetFilteredList(CardSearchModel Model);
CardViewModel? GetElement(CardSearchModel Model);
CardViewModel? Insert(CardBindingModel Model);
CardViewModel? Update(CardBindingModel Model);
CardViewModel? Delete(CardBindingModel Model);
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.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 DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.StorageContracts
{
public interface IDrinkStorage
{
List<DrinkViewModel> GetFullList();
List<DrinkViewModel> GetFilteredList(DrinkSearchModel Model);
DrinkViewModel? GetElement(DrinkSearchModel Model);
DrinkViewModel? Insert(DrinkBindingModel Model);
DrinkViewModel? Update(DrinkBindingModel Model);
DrinkViewModel? Delete(DrinkBindingModel Model);
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.StorageContracts
{
public interface IOrderStorage
{
List<OrderViewModel> GetFullList();
List<OrderViewModel> GetFilteredList(OrderSearchModel model);
OrderViewModel? GetElement(OrderSearchModel model);
OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model);
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
namespace DiningRoomContracts.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,21 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.SearchModels;
using DiningRoomContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.StorageContracts
{
public interface IUserStorage
{
List<UserViewModel> GetFullList();
List<UserViewModel> GetFilteredList(UserSearchModel model);
UserViewModel? GetElement(UserSearchModel model);
UserViewModel? Insert(UserBindingModel model);
UserViewModel? Update(UserBindingModel model);
UserViewModel? Delete(UserBindingModel model);
}
}

View File

@ -0,0 +1,17 @@
using DiningRoomDataModels.Models;
using System.ComponentModel;
namespace DiningRoomContracts.ViewModels
{
public class CardViewModel : ICardModel
{
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Название карты")]
public string CardName { get; set; } = string.Empty;
public Dictionary<int, (IDrinkModel, int)> DrinkCard { get; set; } = new();
}
}

View File

@ -0,0 +1,21 @@
using DiningRoomDataModels.Models;
using System.ComponentModel;
namespace DiningRoomContracts.ViewModels
{
public class ComponentViewModel : IComponentModel
{
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Название продукта")]
public string ComponentName { get; set; } = string.Empty;
[DisplayName("Единица измерения")]
public string Unit { get; set; } = string.Empty;
[DisplayName("Стоимость")]
public double Cost { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using DiningRoomDataModels.Models;
using System.ComponentModel;
namespace DiningRoomContracts.ViewModels
{
public class DrinkViewModel : IDrinkModel
{
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Название товара")]
public string DrinkName { get; set; } = string.Empty;
[DisplayName("Стоимость")]
public double Cost { get; set; }
public Dictionary<int, (IComponentModel, int)> DrinkComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,29 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.ViewModels
{
public class OrderViewModel : IOrderModel
{
[DisplayName("Номер")]
public int Id { get; set; }
public int UserId { get; set; }
[DisplayName("Дата Создания")]
public DateTime DateCreate { get; set; } = DateTime.Now;
public Dictionary<int, (IProductModel, int)> ProductOrder { get; set; } = new();
public Dictionary<int, (IDrinkModel, int)> DrinkOrder { get; set; } = new();
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Стоимость")]
public double Sum { get; set; }
}
}

View File

@ -0,0 +1,19 @@
using DiningRoomDataModels.Models;
using System.ComponentModel;
namespace DiningRoomContracts.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; }
public Dictionary<int, (IComponentModel, int)> ProductComponents { get; set; } = new();
}
}

View File

@ -0,0 +1,27 @@
using DiningRoomDataModels.Enums;
using DiningRoomDataModels.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DiningRoomContracts.ViewModels
{
public class UserViewModel : IUserModel
{
public int Id { get; set; }
[DisplayName("Логин")]
public string Login { get; set; } = string.Empty;
[DisplayName("Пароль")]
public string Password { get; set; } = string.Empty;
[DisplayName("Почта")]
public string Email { get; set; } = string.Empty;
}
}

View File

@ -18,10 +18,6 @@
/// Единица измерения
/// </summary>
string Unit { get; }
/// <summary>
/// Количество
/// </summary>
int count { get; }
/// <summary>
/// Цена продукта

View File

@ -23,6 +23,6 @@
/// <summary>
/// Список комплектующих
/// </summary>
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
Dictionary<int, (IComponentModel, int)> DrinkComponents { get; }
}
}

View File

@ -21,7 +21,7 @@
double Cost { get; }
/// <summary>
/// Список комплектующих
/// Список продуктов
/// </summary>
Dictionary<int, (IComponentModel, int)> ProductComponents { get; }
}