fix commit 1.1

This commit is contained in:
Denis 2023-04-07 17:58:07 +03:00
parent 0ce6ffd4eb
commit 7c8efd4ea7
40 changed files with 332 additions and 101 deletions

View File

@ -17,8 +17,6 @@ namespace CanteenContracts.BindingModels
public string Patronymic { get; set; } = string.Empty; public string Patronymic { get; set; } = string.Empty;
public string Position { get; set; } public string Position { get; set; } = string.Empty;
} }
} }

View File

@ -4,9 +4,10 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models namespace CanteenContracts.BindingModels
{ {
public class ProductLunch public class CookLinkBindingModel
{ {
public int Id { get; set; }
} }
} }

View File

@ -13,6 +13,6 @@ namespace CanteenContracts.BindingModels
public string DishName { get; set; } = string.Empty; public string DishName { get; set; } = string.Empty;
public double Cost { get; set; } public double Cost { get; set; }
public int ManagerId { get; set; } public int ManagerId { get; set; }
public Dictionary<int, IProductModel> DishProducts { get; set; } = new(); public Dictionary<int, (IProductModel, int)> DishProducts { get; set; } = new();
} }
} }

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenContracts.BindingModels
{
public class DishLinkBindingModel
{
public int Id { get; set; }
}
}

View File

@ -14,9 +14,7 @@ namespace CanteenContracts.BindingModels
public int VisitorId { get; set; } public int VisitorId { get; set; }
public string LunchName { get; set; } = string.Empty; public string LunchName { get; set; } = string.Empty;
public double Cost { get; set; } public double Cost { get; set; }
public DateTime DateCreate { get; set; } = DateTime.Now; public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new();
public Dictionary<int, IProductModel> LunchProducts { get; set; } = new();
public Dictionary<int, IOrderModel> LunchOrders { get; set; } = new();
} }

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenContracts.BindingModels
{
public class LunchLinkBindingModel
{
public int Id { get; set; }
}
}

View File

@ -12,8 +12,8 @@ namespace CanteenContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int VisitorId { get; set; } public int VisitorId { get; set; }
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public double Sum { get; set; }
public DateTime DateCreate { get; } = DateTime.Now;
} }
} }

View File

@ -12,9 +12,10 @@ namespace CanteenContracts.BusinessLogicsContracts
public interface IOrderLogic public interface IOrderLogic
{ {
List<OrderViewModel>? ReadList(OrderSearchModel? model); List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model); bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model); bool AddLunch(LunchLinkBindingModel model);
bool FinishOrder(OrderBindingModel model); bool AddDish(DishLinkBindingModel model);
bool DeliveryOrder(OrderBindingModel model); bool AddCook(CookLinkBindingModel model);
} }
} }

View File

@ -12,7 +12,6 @@
<ItemGroup> <ItemGroup>
<Folder Include="ViewModels\" /> <Folder Include="ViewModels\" />
<Folder Include="BindingModels\" />
<Folder Include="BusinessLogicsContracts\" /> <Folder Include="BusinessLogicsContracts\" />
<Folder Include="SearchModels\" /> <Folder Include="SearchModels\" />
<Folder Include="StoragesContracts\" /> <Folder Include="StoragesContracts\" />

View File

@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
public class CookSearchModel public class CookSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ManagerId { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public string? Surname { get; set; } public string? Surname { get; set; }
public string? Patronymic { get; set; } public string? Patronymic { get; set; }

View File

@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
public class DishSearchModel public class DishSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ManagerId { get; set; }
public string? DishName { get; set; } public string? DishName { get; set; }
} }
} }

View File

@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
public class LunchSearchModel public class LunchSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? VisitorId { get; set; }
public string? LunchName { get; set; } public string? LunchName { get; set; }
} }
} }

View File

@ -9,7 +9,7 @@ namespace CanteenContracts.SearchModel
public class OrderSearchModel public class OrderSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; } public int? VisitorId { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
} }

View File

@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
public class ProductSearchModel public class ProductSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ManagerId { get; set; }
public string? ProductName { get; set; } public string? ProductName { get; set; }
} }
} }

View File

@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
public class TablewareSearchModel public class TablewareSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? VisitorId { get; set; }
public string? TablewareName { get; set; } public string? TablewareName { get; set; }
} }
} }

View File

@ -17,5 +17,8 @@ namespace CanteenContracts.StoragesContracts
OrderViewModel? Insert(OrderBindingModel model); OrderViewModel? Insert(OrderBindingModel model);
OrderViewModel? Update(OrderBindingModel model); OrderViewModel? Update(OrderBindingModel model);
OrderViewModel? Delete(OrderBindingModel model); OrderViewModel? Delete(OrderBindingModel model);
OrderViewModel? AddLunch(LunchLinkBindingModel model);
OrderViewModel? AddDish(DishLinkBindingModel model);
OrderViewModel? AddCook(CookLinkBindingModel model);
} }
} }

View File

@ -16,8 +16,6 @@ namespace CanteenContracts.View
public string Surname { get; set; } = string.Empty; public string Surname { get; set; } = string.Empty;
[DisplayName("Отчество")] [DisplayName("Отчество")]
public string? Patronymic { get; set; } = string.Empty; public string? Patronymic { get; set; } = string.Empty;
[DisplayName("Дата рождения")]
public DateTime DateOfBirth { get; set; }
[DisplayName("Должность")] [DisplayName("Должность")]
public string Position { get; set; } = string.Empty; public string Position { get; set; } = string.Empty;

View File

@ -11,11 +11,11 @@ namespace CanteenContracts.View
public class DishViewModel : IDishModel public class DishViewModel : IDishModel
{ {
public int Id { get; set; } public int Id { get; set; }
public int VisitorId { get; set; } public int ManagerId { get; set; }
public int ProductId { get; set; }
[DisplayName("Название блюда")] [DisplayName("Название блюда")]
public string DishName { get; set; } = string.Empty; public string DishName { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Cost { get; set; } public double Cost { get; set; }
public Dictionary<int, (IProductModel, int)> DishProducts { get; set; } = new();
} }
} }

View File

@ -13,23 +13,13 @@ namespace CanteenContracts.View
{ {
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int LunchId { get; set; } public int VisitorId { get; set; }
public int ClientId { get; set; }
[DisplayName("ФИО посетителя")] [DisplayName("ФИО посетителя")]
public string ClientFIO { get; set; } = string.Empty; public string VisitorFIO { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty;
[DisplayName("Обед")]
public string LunchName { get; set; } = string.Empty;
[DisplayName("Количество")]
public int Count { get; set; }
[DisplayName("Сумма")] [DisplayName("Сумма")]
public double Sum { get; set; } public double Sum { get; set; }
[DisplayName("Статус")]
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
[DisplayName("Дата создания")] [DisplayName("Дата создания")]
public DateTime DateCreate { get; set; } = DateTime.Now; public DateTime DateCreate { get; set; } = DateTime.Now;
[DisplayName("Дата выполнения")]
public DateTime? DateImplement { get; set; }
} }
} }

View File

@ -10,15 +10,12 @@ namespace CanteenContracts.View
{ {
public class ProductViewModel : IProductModel public class ProductViewModel : IProductModel
{ {
public int Id { get; set; }
public int ManagerId { get; set; }
[DisplayName("Название продукта")] [DisplayName("Название продукта")]
public string ProductName { get; set; } = string.Empty; public string ProductName { get; set; } = string.Empty;
[DisplayName("Цена")] [DisplayName("Цена")]
public double Cost { get; set; } public double Cost { get; set; }
public int ManagerId { get; set; }
public Dictionary<int, ICookModel> ProductCooks { get; set; } = new(); public Dictionary<int, ICookModel> ProductCooks { get; set; } = new();
public int Id { get; set; }
} }
} }

View File

@ -10,13 +10,13 @@ namespace CanteenContracts.View
{ {
public class TablewareViewModel : ITablewareModel public class TablewareViewModel : ITablewareModel
{ {
public int Id { get; set; }
public int VisitorId { get; set; }
public int OrderId { get; set; }
[DisplayName("Название прибора")] [DisplayName("Название прибора")]
public string TablewareName { get; set; } = string.Empty; public string TablewareName { get; set; } = string.Empty;
public int ClientId { get; set; } public int Count { get; set; }
public int OrderId { get; set; }
public int Id { get; set; }
} }
} }

View File

@ -10,6 +10,7 @@ namespace CanteenContracts.View
{ {
public class VisitorViewModel : IVisitorModel public class VisitorViewModel : IVisitorModel
{ {
public int Id { get; set; }
[DisplayName("ФИО посетителя")] [DisplayName("ФИО посетителя")]
public string FIO { get; set; } = string.Empty; public string FIO { get; set; } = string.Empty;
[DisplayName("Логин")] [DisplayName("Логин")]
@ -18,9 +19,6 @@ namespace CanteenContracts.View
public string Password { get; set; } = string.Empty; public string Password { get; set; } = string.Empty;
[DisplayName("Номер телефона")] [DisplayName("Номер телефона")]
public string PhoneNumber { get; set; } = string.Empty; public string PhoneNumber { get; set; } = string.Empty;
public int RoleId { get; set; } public int RoleId { get; set; }
public int Id { get; set; }
} }
} }

View File

@ -8,7 +8,6 @@ namespace CanteenDataModels.Models
{ {
public interface ICookModel : IId public interface ICookModel : IId
{ {
int Id { get; }
int ManagerId { get; } int ManagerId { get; }
string Name { get; } string Name { get; }

View File

@ -8,10 +8,9 @@ namespace CanteenDataModels.Models
{ {
public interface IDishModel : IId public interface IDishModel : IId
{ {
int Id { get; }
string DishName { get; } string DishName { get; }
double Cost { get; } double Cost { get; }
int ManagerId { get; } int ManagerId { get; }
Dictionary<int, IProductModel> DishProducts { get; } Dictionary<int, (IProductModel, int)> DishProducts { get; }
} }
} }

View File

@ -8,12 +8,9 @@ namespace CanteenDataModels.Models
{ {
public interface ILunchModel : IId public interface ILunchModel : IId
{ {
int Id { get; }
int VisitorId { get; } int VisitorId { get; }
string LunchName { get; } string LunchName { get; }
double Cost { get; } double Cost { get; }
DateTime DateCreate { get; } Dictionary<int, (IProductModel, int)> LunchProducts { get; }
Dictionary<int, IProductModel> LunchProducts { get; }
Dictionary<int, IOrderModel> LunchOrders { get; }
} }
} }

View File

@ -8,7 +8,6 @@ namespace CanteenDataModels.Models
{ {
public interface IManagerModel : IId public interface IManagerModel : IId
{ {
int Id { get; }
string FIO { get; } string FIO { get; }
string Login { get; } string Login { get; }

View File

@ -9,9 +9,9 @@ namespace CanteenDataModels.Models
{ {
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int Id { get; }
int VisitorId { get; } int VisitorId { get; }
string Description { get; } string Description { get; }
double Sum { get; }
DateTime DateCreate { get; }
} }
} }

View File

@ -8,8 +8,9 @@ namespace CanteenDataModels.Models
{ {
public interface ITablewareModel : IId public interface ITablewareModel : IId
{ {
string TablewareName { get; } int VisitorId { get; }
int ManagerId { get; }
int OrderId { get; } int OrderId { get; }
string TablewareName { get; }
int Count { get; }
} }
} }

View File

@ -14,15 +14,16 @@ namespace CanteenDatabaseImplement
base.OnConfiguring(optionsBuilder); base.OnConfiguring(optionsBuilder);
} }
public virtual DbSet<Cook> Cooks { set; get; } public virtual DbSet<Cook> Cooks { set; get; }
public virtual DbSet<CookOrder> OrderCooks { set; get; } public virtual DbSet<OrderCook> OrderCooks { set; get; }
public virtual DbSet<Dish> Dishes { set; get; } public virtual DbSet<Dish> Dishes { set; get; }
public virtual DbSet<Lunch> Lunches { set; get; } public virtual DbSet<Lunch> Lunches { set; get; }
public virtual DbSet<LunchOrder> OrderLunches { set; get; } public virtual DbSet<OrderLunch> OrderLunches { set; get; }
public virtual DbSet<Manager> Managers { set; get; } public virtual DbSet<Manager> Managers { set; get; }
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Product> Products { set; get; } public virtual DbSet<Product> Products { set; get; }
public virtual DbSet<ProductCook> ProductCooks { set; get; } public virtual DbSet<ProductCook> ProductCooks { set; get; }
public virtual DbSet<ProductLunch> LunchProducts { set; get; } public virtual DbSet<LunchProduct> LunchProducts { set; get; }
public virtual DbSet<DishProduct> DishProducts { set; get; }
public virtual DbSet<Role> Roles { set; get; } public virtual DbSet<Role> Roles { set; get; }
public virtual DbSet<Tableware> Tablewares { set; get; } public virtual DbSet<Tableware> Tablewares { set; get; }
public virtual DbSet<Visitor> Visitors { set; get; } public virtual DbSet<Visitor> Visitors { set; get; }

View File

@ -11,23 +11,19 @@ namespace CanteenDatabaseImplement.Models
{ {
public class Cook : ICookModel public class Cook : ICookModel
{ {
public int Id { get; private set; }
[Required]
public int ManagerId { get; private set; }
[Required] [Required]
public string Name { get; private set; } = string.Empty; public string Name { get; private set; } = string.Empty;
[Required] [Required]
public string Surname { get; private set; } = string.Empty; public string Surname { get; private set; } = string.Empty;
public string? Patronymic { get; private set; } = string.Empty; public string? Patronymic { get; private set; } = string.Empty;
[Required] [Required]
public DateTime DateOfBirth { get; private set; }
[Required]
public string Position { get; private set; } = string.Empty; public string Position { get; private set; } = string.Empty;
[Required]
public int ManagerId { get; private set; }
public int Id { get; private set; }
[ForeignKey("CookId")] [ForeignKey("CookId")]
public virtual List<ProductCook> Products{ get; set; } = new(); public virtual List<ProductCook> Products{ get; set; } = new();
[ForeignKey("CookId")] [ForeignKey("CookId")]
public virtual List<CookOrder> Orders { get; set; } = new(); public virtual List<OrderCook> Orders { get; set; } = new();
} }
} }

View File

@ -1,12 +1,93 @@
using System; using CanteenContracts.BindingModels;
using CanteenContracts.View;
using CanteenDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Globalization;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models namespace CanteenDatabaseImplement.Models
{ {
public class Dish public class Dish : IDishModel
{ {
public int Id { get; private set; }
[Required]
public string DishName { get; private set; } = string.Empty;
[Required]
public double Cost { get; private set; }
[Required]
public int ManagerId { get; private set; }
private Dictionary<int, (IProductModel, int)>? _dishProducts = null;
public Dictionary<int, (IProductModel, int)> DishProduct
{
get
{
if (_dishProducts == null)
{
_dishProducts = Products
.ToDictionary(recPC => recPC.ProductId, recPC => (recPC.Product as IProductModel, recPC.CountProduct));
}
return _dishProducts;
}
}
[ForeignKey("DishId")]
public virtual List<DishProduct> Products { get; set; } = new();
public static Dish? Create(CanteenDatabase context, DishBindingModel model)
{
return new Dish()
{
Id = model.Id,
DishName = model.DishName,
Cost = model.Cost,
Products = model.DishProducts.Select(x => new DishProduct
{
Product = context.Products.First(y => y.Id == x.Key)
}).ToList()
};
}
public void Update(DishBindingModel model)
{
DishName = model.DishName;
Cost = model.Cost;
}
public DishViewModel GetViewModel => new()
{
Id = Id,
DishName = DishName,
Cost = Cost,
DishProducts = DishProduct,
ManagerId = ManagerId
};
public Dictionary<int, (IProductModel, int)> DishProducts => throw new NotImplementedException();
public void UpdateProduct(CanteenDatabase context, DishBindingModel model)
{
var dishProducts = context.DishProducts.Where(record => record.ProductId == model.Id).ToList();
if (dishProducts != null && dishProducts.Count > 0)
{
context.DishProducts.RemoveRange(dishProducts.Where(record => !model.DishProducts.ContainsKey(record.ProductId)));
context.SaveChanges();
}
var product = context.Products.First(x => x.Id == Id);
foreach (var pc in model.DishProducts)
{
context.DishProducts.Add(new DishProduct
{
Product = product,
Dish = context.Dishes.First(x => x.Id == pc.Key),
});
context.SaveChanges();
}
_dishProducts = null;
}
} }
} }

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models
{
public class DishProduct
{
public int Id { get; set; }
[Required]
public int DishId { get; set; }
[Required]
public int ProductId { get; set; }
[Required]
public int CountProduct { get; set; }
public virtual Dish Dish { get; set; } = new();
public virtual Product Product { get; set; } = new();
}
}

View File

@ -1,22 +1,89 @@
using CanteenDataModels.Models; using CanteenDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using CanteenContracts.BindingModels;
using CanteenContracts.View;
namespace CanteenDatabaseImplement.Models namespace CanteenDatabaseImplement.Models
{ {
public class Lunch : ILunchModel public class Lunch : ILunchModel
{ {
public string LunchName => throw new NotImplementedException(); public int Id { get; private set; }
public int VisitorId { get; private set; }
public double Cost => throw new NotImplementedException(); public string LunchName { get; private set; } = string.Empty;
public double Cost { get; private set; }
public int VisitorId => throw new NotImplementedException(); private Dictionary<int, (IProductModel, int)>? _lunchProducts = null;
public Dictionary<int, (IProductModel, int)> LunchProducts
public Dictionary<int, (IProductModel, int)> LunchProducts => throw new NotImplementedException(); {
get
public int Id => throw new NotImplementedException(); {
if (_lunchProducts == null)
{
_lunchProducts = Products
.ToDictionary(recPC => recPC.ProductId, recPC => (recPC.Product as IProductModel, recPC.CountProduct));
}
return _lunchProducts;
}
}
[ForeignKey("LunchId")]
public virtual List<OrderLunch> Orders { get; set; } = new();
public virtual List<LunchProduct> Products { get; set; } = new();
public static Lunch? Create(CanteenDatabase context, LunchBindingModel model)
{
return new Lunch()
{
Id = model.Id,
VisitorId = model.VisitorId,
LunchName = model.LunchName,
Cost = model.Cost,
Products = model.LunchProducts.Select(x => new LunchProduct
{
Product = context.Products.First(y => y.Id == x.Key)
}).ToList()
};
}
public void Update(LunchBindingModel model)
{
LunchName = model.LunchName;
Cost = model.Cost;
}
public LunchViewModel GetViewModel => new()
{
Id = Id,
VisitorId = VisitorId,
LunchName = LunchName,
Cost = Cost,
LunchProducts = LunchProducts
};
public void UpdateProduct(CanteenDatabase context, LunchBindingModel model)
{
var lunchProducts = context.LunchProducts.Where(record => record.ProductId == model.Id).ToList();
if (lunchProducts != null && lunchProducts.Count > 0)
{
context.LunchProducts.RemoveRange(lunchProducts.Where(record => !model.LunchProducts.ContainsKey(record.ProductId)));
context.SaveChanges();
}
var product = context.Products.First(x => x.Id == Id);
foreach (var pc in model.LunchProducts)
{
context.LunchProducts.Add(new LunchProduct
{
Product = product,
Lunch = context.Lunches.First(x => x.Id == pc.Key),
});
context.SaveChanges();
}
_lunchProducts = null;
}
} }
} }

View File

@ -6,7 +6,7 @@ using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models namespace CanteenDatabaseImplement.Models
{ {
public class LunchOrder public class LunchProduct
{ {
} }
} }

View File

@ -2,6 +2,7 @@
using CanteenDataModels.Models; using CanteenDataModels.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -11,20 +12,22 @@ namespace CanteenDatabaseImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int ClientId { get; private set; }
public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
public DateTime DateCreate { get; private set; } = DateTime.Now;
public DateTime? DateImplement { get; private set; }
public int Id { get; private set; } public int Id { get; private set; }
[Required]
public int VisitorId { get; private set; }
[Required]
public string Description { get; private set; } = string.Empty;
[Required]
public double Sum { get; private set; }
[Required]
public DateTime DateCreate { get; private set; } = DateTime.Now;
[ForeignKey("OrderId")] [ForeignKey("OrderId")]
public virtual List<LunchOrder> LunchOrders { get; set; } = new(); public virtual List<OrderLunch> OrderLunches { get; set; } = new();
[ForeignKey("OrderId")] [ForeignKey("OrderId")]
public virtual List<CookOrder> CookOrders { get; set; } = new(); public virtual List<OrderCook> OrderCooks { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<OrderDish> OrderDishes { get; set; } = new();
[ForeignKey("OrderId")]
public virtual List<OrderTableware> Orderablewares { get; set; } = new();
} }
} }

View File

@ -7,18 +7,14 @@ using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models namespace CanteenDatabaseImplement.Models
{ {
public class CookOrder public class OrderCook
{ {
public int Id { get; set; } public int Id { get; set; }
[Required] [Required]
public int CookId { get; set; } public int CookId { get; set; }
[Required] [Required]
public int OrderId { get; set; } public int OrderId { get; set; }
public virtual Order Order { get; set; } = new(); public virtual Order Order { get; set; } = new();
public virtual Cook Cook { get; set; } = new(); public virtual Cook Cook { get; set; } = new();
} }
} }

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models
{
public class OrderLunch
{
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int LunchId { get; set; }
[Required]
public int CountProduct { get; set; }
public virtual Order Order { get; set; } = new();
public virtual Lunch Lunch { get; set; } = new();
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models
{
public class OrderTableware
{
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int TablewareId { get; set; }
[Required]
public int Count { get; set; }
public virtual Order Order { get; set; } = new();
public virtual Tableware Tableware { get; set; } = new();
}
}

View File

@ -8,16 +8,14 @@ namespace CanteenDatabaseImplement.Models
{ {
public class Product : IProductModel public class Product : IProductModel
{ {
public int Id { get; private set; }
[Required] [Required]
public string ProductName { get; private set; } = string.Empty; public string ProductName { get; private set; } = string.Empty;
[Required] [Required]
public double Cost { get; private set; } public double Cost { get; private set; }
[Required] [Required]
public int ManagerId { get; private set; } public int ManagerId { get; private set; }
private Dictionary<int, ICookModel>? _productCooks = null; private Dictionary<int, ICookModel>? _productCooks = null;
public int Id { get; private set; }
[NotMapped] [NotMapped]
public Dictionary<int, ICookModel> ProductCooks public Dictionary<int, ICookModel> ProductCooks
{ {
@ -32,9 +30,8 @@ namespace CanteenDatabaseImplement.Models
} }
[ForeignKey("ProductId")] [ForeignKey("ProductId")]
public virtual List<ProductCook> Cooks { get; set; } = new(); public virtual List<ProductCook> Cooks { get; set; } = new();
[ForeignKey("ProductId")] [ForeignKey("ProductId")]
public virtual List<Order> Lunches { get; set; } = new(); public virtual List<DishProduct> Dishes { get; set; } = new();
public static Product? Create(CanteenDatabase context, ProductBindingModel model) public static Product? Create(CanteenDatabase context, ProductBindingModel model)
{ {
return new Product() return new Product()

View File

@ -1,12 +1,26 @@
using System; using CanteenDataModels.Models;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace CanteenDatabaseImplement.Models namespace CanteenDatabaseImplement.Models
{ {
public class Tableware public class Tableware : ITablewareModel
{ {
public int Id { get; private set; }
[Required]
public int VisitorId { get; private set; }
[Required]
public int OrderId { get; private set; }
[Required]
public string TablewareName { get; private set; } = string.Empty;
[Required]
public int Count { get; private set; }
[ForeignKey("TablewareId")]
public virtual List<OrderTableware> Orders { get; set; } = new();
} }
} }