fix commit 1.1
This commit is contained in:
parent
0ce6ffd4eb
commit
7c8efd4ea7
@ -17,8 +17,6 @@ namespace CanteenContracts.BindingModels
|
||||
|
||||
public string Patronymic { get; set; } = string.Empty;
|
||||
|
||||
public string Position { get; set; }
|
||||
|
||||
|
||||
public string Position { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,10 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public class ProductLunch
|
||||
public class CookLinkBindingModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
@ -13,6 +13,6 @@ namespace CanteenContracts.BindingModels
|
||||
public string DishName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
public Dictionary<int, IProductModel> DishProducts { get; set; } = new();
|
||||
public Dictionary<int, (IProductModel, int)> DishProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -14,9 +14,7 @@ namespace CanteenContracts.BindingModels
|
||||
public int VisitorId { get; set; }
|
||||
public string LunchName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
public Dictionary<int, IProductModel> LunchProducts { get; set; } = new();
|
||||
public Dictionary<int, IOrderModel> LunchOrders { get; set; } = new();
|
||||
public Dictionary<int, (IProductModel, int)> LunchProducts { get; set; } = new();
|
||||
|
||||
|
||||
}
|
||||
|
@ -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; }
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ namespace CanteenContracts.BindingModels
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public double Sum { get; set; }
|
||||
public DateTime DateCreate { get; } = DateTime.Now;
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ namespace CanteenContracts.BusinessLogicsContracts
|
||||
public interface IOrderLogic
|
||||
{
|
||||
List<OrderViewModel>? ReadList(OrderSearchModel? model);
|
||||
OrderViewModel? ReadElement(OrderSearchModel model);
|
||||
bool CreateOrder(OrderBindingModel model);
|
||||
bool TakeOrderInWork(OrderBindingModel model);
|
||||
bool FinishOrder(OrderBindingModel model);
|
||||
bool DeliveryOrder(OrderBindingModel model);
|
||||
bool AddLunch(LunchLinkBindingModel model);
|
||||
bool AddDish(DishLinkBindingModel model);
|
||||
bool AddCook(CookLinkBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="ViewModels\" />
|
||||
<Folder Include="BindingModels\" />
|
||||
<Folder Include="BusinessLogicsContracts\" />
|
||||
<Folder Include="SearchModels\" />
|
||||
<Folder Include="StoragesContracts\" />
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class CookSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ManagerId { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Surname { get; set; }
|
||||
public string? Patronymic { get; set; }
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class DishSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ManagerId { get; set; }
|
||||
public string? DishName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class LunchSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? VisitorId { get; set; }
|
||||
public string? LunchName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class OrderSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ClientId { get; set; }
|
||||
public int? VisitorId { get; set; }
|
||||
public DateTime? DateFrom { get; set; }
|
||||
public DateTime? DateTo { get; set; }
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class ProductSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? ManagerId { get; set; }
|
||||
public string? ProductName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ namespace CanteenContracts.SearchModel
|
||||
public class TablewareSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public int? VisitorId { get; set; }
|
||||
public string? TablewareName { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -17,5 +17,8 @@ namespace CanteenContracts.StoragesContracts
|
||||
OrderViewModel? Insert(OrderBindingModel model);
|
||||
OrderViewModel? Update(OrderBindingModel model);
|
||||
OrderViewModel? Delete(OrderBindingModel model);
|
||||
OrderViewModel? AddLunch(LunchLinkBindingModel model);
|
||||
OrderViewModel? AddDish(DishLinkBindingModel model);
|
||||
OrderViewModel? AddCook(CookLinkBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ namespace CanteenContracts.View
|
||||
public string Surname { get; set; } = string.Empty;
|
||||
[DisplayName("Отчество")]
|
||||
public string? Patronymic { get; set; } = string.Empty;
|
||||
[DisplayName("Дата рождения")]
|
||||
public DateTime DateOfBirth { get; set; }
|
||||
[DisplayName("Должность")]
|
||||
public string Position { get; set; } = string.Empty;
|
||||
|
||||
|
@ -11,11 +11,11 @@ namespace CanteenContracts.View
|
||||
public class DishViewModel : IDishModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
public int ProductId { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
[DisplayName("Название блюда")]
|
||||
public string DishName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
public Dictionary<int, (IProductModel, int)> DishProducts { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -13,23 +13,13 @@ namespace CanteenContracts.View
|
||||
{
|
||||
[DisplayName("Номер")]
|
||||
public int Id { get; set; }
|
||||
public int LunchId { get; set; }
|
||||
|
||||
public int ClientId { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
[DisplayName("ФИО посетителя")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Обед")]
|
||||
public string LunchName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
public string VisitorFIO { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||
[DisplayName("Дата создания")]
|
||||
public DateTime DateCreate { get; set; } = DateTime.Now;
|
||||
[DisplayName("Дата выполнения")]
|
||||
public DateTime? DateImplement { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,15 +10,12 @@ namespace CanteenContracts.View
|
||||
{
|
||||
public class ProductViewModel : IProductModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ManagerId { get; set; }
|
||||
[DisplayName("Название продукта")]
|
||||
public string ProductName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
|
||||
public int ManagerId { get; set; }
|
||||
|
||||
public Dictionary<int, ICookModel> ProductCooks { get; set; } = new();
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,13 +10,13 @@ namespace CanteenContracts.View
|
||||
{
|
||||
public class TablewareViewModel : ITablewareModel
|
||||
{
|
||||
|
||||
public int Id { get; set; }
|
||||
public int VisitorId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
[DisplayName("Название прибора")]
|
||||
public string TablewareName { get; set; } = string.Empty;
|
||||
|
||||
public int ClientId { get; set; }
|
||||
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
public int Count { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ namespace CanteenContracts.View
|
||||
{
|
||||
public class VisitorViewModel : IVisitorModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("ФИО посетителя")]
|
||||
public string FIO { get; set; } = string.Empty;
|
||||
[DisplayName("Логин")]
|
||||
@ -18,9 +19,6 @@ namespace CanteenContracts.View
|
||||
public string Password { get; set; } = string.Empty;
|
||||
[DisplayName("Номер телефона")]
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
|
||||
public int RoleId { get; set; }
|
||||
|
||||
public int Id { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface ICookModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int ManagerId { get; }
|
||||
string Name { get; }
|
||||
|
||||
|
@ -8,10 +8,9 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IDishModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
string DishName { get; }
|
||||
double Cost { get; }
|
||||
int ManagerId { get; }
|
||||
Dictionary<int, IProductModel> DishProducts { get; }
|
||||
Dictionary<int, (IProductModel, int)> DishProducts { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,12 +8,9 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface ILunchModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int VisitorId { get; }
|
||||
string LunchName { get; }
|
||||
double Cost { get; }
|
||||
DateTime DateCreate { get; }
|
||||
Dictionary<int, IProductModel> LunchProducts { get; }
|
||||
Dictionary<int, IOrderModel> LunchOrders { get; }
|
||||
Dictionary<int, (IProductModel, int)> LunchProducts { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IManagerModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
string FIO { get; }
|
||||
|
||||
string Login { get; }
|
||||
|
@ -9,9 +9,9 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface IOrderModel : IId
|
||||
{
|
||||
int Id { get; }
|
||||
int VisitorId { get; }
|
||||
|
||||
string Description { get; }
|
||||
double Sum { get; }
|
||||
DateTime DateCreate { get; }
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,9 @@ namespace CanteenDataModels.Models
|
||||
{
|
||||
public interface ITablewareModel : IId
|
||||
{
|
||||
string TablewareName { get; }
|
||||
int ManagerId { get; }
|
||||
int VisitorId { get; }
|
||||
int OrderId { get; }
|
||||
string TablewareName { get; }
|
||||
int Count { get; }
|
||||
}
|
||||
}
|
||||
|
@ -14,15 +14,16 @@ namespace CanteenDatabaseImplement
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
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<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<Order> Orders { set; get; }
|
||||
public virtual DbSet<Product> Products { 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<Tableware> Tablewares { set; get; }
|
||||
public virtual DbSet<Visitor> Visitors { set; get; }
|
||||
|
@ -11,23 +11,19 @@ namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Cook : ICookModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public int ManagerId { get; private set; }
|
||||
[Required]
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Surname { get; private set; } = string.Empty;
|
||||
|
||||
public string? Patronymic { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public DateTime DateOfBirth { get; private set; }
|
||||
[Required]
|
||||
public string Position { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int ManagerId { get; private set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
[ForeignKey("CookId")]
|
||||
public virtual List<ProductCook> Products{ get; set; } = new();
|
||||
[ForeignKey("CookId")]
|
||||
public virtual List<CookOrder> Orders { get; set; } = new();
|
||||
public virtual List<OrderCook> Orders { get; set; } = new();
|
||||
}
|
||||
}
|
||||
|
@ -1,12 +1,93 @@
|
||||
using System;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.View;
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
22
Canteen/CanteenDatabaseImplement/Models/DishProduct.cs
Normal file
22
Canteen/CanteenDatabaseImplement/Models/DishProduct.cs
Normal 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();
|
||||
}
|
||||
}
|
@ -1,22 +1,89 @@
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CanteenContracts.BindingModels;
|
||||
using CanteenContracts.View;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Lunch : ILunchModel
|
||||
{
|
||||
public string LunchName => throw new NotImplementedException();
|
||||
public int Id { get; private set; }
|
||||
public int VisitorId { get; private set; }
|
||||
public string LunchName { get; private set; } = string.Empty;
|
||||
public double Cost { get; private set; }
|
||||
private Dictionary<int, (IProductModel, int)>? _lunchProducts = null;
|
||||
public Dictionary<int, (IProductModel, int)> LunchProducts
|
||||
{
|
||||
get
|
||||
{
|
||||
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 double Cost => throw new NotImplementedException();
|
||||
public void Update(LunchBindingModel model)
|
||||
{
|
||||
LunchName = model.LunchName;
|
||||
Cost = model.Cost;
|
||||
}
|
||||
|
||||
public int VisitorId => throw new NotImplementedException();
|
||||
public LunchViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
VisitorId = VisitorId,
|
||||
LunchName = LunchName,
|
||||
Cost = Cost,
|
||||
LunchProducts = LunchProducts
|
||||
};
|
||||
|
||||
public Dictionary<int, (IProductModel, int)> LunchProducts => throw new NotImplementedException();
|
||||
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();
|
||||
}
|
||||
|
||||
public int Id => throw new NotImplementedException();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class LunchOrder
|
||||
public class LunchProduct
|
||||
{
|
||||
}
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -11,20 +12,22 @@ namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
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; }
|
||||
[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")]
|
||||
public virtual List<LunchOrder> LunchOrders { get; set; } = new();
|
||||
public virtual List<OrderLunch> OrderLunches { get; set; } = new();
|
||||
[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();
|
||||
}
|
||||
}
|
||||
|
@ -7,18 +7,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class CookOrder
|
||||
public class OrderCook
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public int CookId { get; set; }
|
||||
|
||||
[Required]
|
||||
public int OrderId { get; set; }
|
||||
|
||||
public virtual Order Order { get; set; } = new();
|
||||
|
||||
public virtual Cook Cook { get; set; } = new();
|
||||
}
|
||||
}
|
22
Canteen/CanteenDatabaseImplement/Models/OrderLunch.cs
Normal file
22
Canteen/CanteenDatabaseImplement/Models/OrderLunch.cs
Normal 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();
|
||||
}
|
||||
}
|
23
Canteen/CanteenDatabaseImplement/Models/OrderTableware.cs
Normal file
23
Canteen/CanteenDatabaseImplement/Models/OrderTableware.cs
Normal 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();
|
||||
}
|
||||
|
||||
}
|
@ -8,16 +8,14 @@ namespace CanteenDatabaseImplement.Models
|
||||
{
|
||||
public class Product : IProductModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string ProductName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; private set; }
|
||||
[Required]
|
||||
public int ManagerId { get; private set; }
|
||||
|
||||
private Dictionary<int, ICookModel>? _productCooks = null;
|
||||
|
||||
public int Id { get; private set; }
|
||||
[NotMapped]
|
||||
public Dictionary<int, ICookModel> ProductCooks
|
||||
{
|
||||
@ -32,9 +30,8 @@ namespace CanteenDatabaseImplement.Models
|
||||
}
|
||||
[ForeignKey("ProductId")]
|
||||
public virtual List<ProductCook> Cooks { get; set; } = new();
|
||||
|
||||
[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)
|
||||
{
|
||||
return new Product()
|
||||
|
@ -1,12 +1,26 @@
|
||||
using System;
|
||||
using CanteenDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user