это работает
This commit is contained in:
parent
2944c500ef
commit
f4bc73c0b6
45
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
45
FoodOrders/FoodOrders/FormMain.Designer.cs
generated
@ -34,6 +34,7 @@
|
|||||||
dishToolStripMenuItem = new ToolStripMenuItem();
|
dishToolStripMenuItem = new ToolStripMenuItem();
|
||||||
clientToolStripMenuItem = new ToolStripMenuItem();
|
clientToolStripMenuItem = new ToolStripMenuItem();
|
||||||
shopsToolStripMenuItem = new ToolStripMenuItem();
|
shopsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
исполнителиToolStripMenuItem1 = new ToolStripMenuItem();
|
||||||
reportToolStripMenuItem = new ToolStripMenuItem();
|
reportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
listDishesToolStripMenuItem = new ToolStripMenuItem();
|
listDishesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
componentDishToolStripMenuItem = new ToolStripMenuItem();
|
componentDishToolStripMenuItem = new ToolStripMenuItem();
|
||||||
@ -50,6 +51,7 @@
|
|||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonAddDishInShop = new Button();
|
buttonAddDishInShop = new Button();
|
||||||
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
исполнителиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
buttonSetToFinish = new Button();
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -59,13 +61,13 @@
|
|||||||
menuStrip.Items.AddRange(new ToolStripItem[] { guidesToolStripMenuItem, reportToolStripMenuItem, DoWorkToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { guidesToolStripMenuItem, reportToolStripMenuItem, DoWorkToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(975, 24);
|
menuStrip.Size = new Size(1157, 24);
|
||||||
menuStrip.TabIndex = 0;
|
menuStrip.TabIndex = 0;
|
||||||
menuStrip.Text = "menuStrip1";
|
menuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// guidesToolStripMenuItem
|
// guidesToolStripMenuItem
|
||||||
//
|
//
|
||||||
guidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentToolStripMenuItem, dishToolStripMenuItem, clientToolStripMenuItem, shopsToolStripMenuItem });
|
guidesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentToolStripMenuItem, dishToolStripMenuItem, clientToolStripMenuItem, shopsToolStripMenuItem, исполнителиToolStripMenuItem1 });
|
||||||
guidesToolStripMenuItem.Name = "guidesToolStripMenuItem";
|
guidesToolStripMenuItem.Name = "guidesToolStripMenuItem";
|
||||||
guidesToolStripMenuItem.Size = new Size(94, 20);
|
guidesToolStripMenuItem.Size = new Size(94, 20);
|
||||||
guidesToolStripMenuItem.Text = "Справочники";
|
guidesToolStripMenuItem.Text = "Справочники";
|
||||||
@ -73,31 +75,38 @@
|
|||||||
// componentToolStripMenuItem
|
// componentToolStripMenuItem
|
||||||
//
|
//
|
||||||
componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
||||||
componentToolStripMenuItem.Size = new Size(180, 22);
|
componentToolStripMenuItem.Size = new Size(149, 22);
|
||||||
componentToolStripMenuItem.Text = "Компоненты";
|
componentToolStripMenuItem.Text = "Компоненты";
|
||||||
componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
componentToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// dishToolStripMenuItem
|
// dishToolStripMenuItem
|
||||||
//
|
//
|
||||||
dishToolStripMenuItem.Name = "dishToolStripMenuItem";
|
dishToolStripMenuItem.Name = "dishToolStripMenuItem";
|
||||||
dishToolStripMenuItem.Size = new Size(180, 22);
|
dishToolStripMenuItem.Size = new Size(149, 22);
|
||||||
dishToolStripMenuItem.Text = "Блюда";
|
dishToolStripMenuItem.Text = "Блюда";
|
||||||
dishToolStripMenuItem.Click += DishToolStripMenuItem_Click;
|
dishToolStripMenuItem.Click += DishToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// clientToolStripMenuItem
|
// clientToolStripMenuItem
|
||||||
//
|
//
|
||||||
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
||||||
clientToolStripMenuItem.Size = new Size(180, 22);
|
clientToolStripMenuItem.Size = new Size(149, 22);
|
||||||
clientToolStripMenuItem.Text = "Клиенты";
|
clientToolStripMenuItem.Text = "Клиенты";
|
||||||
clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
|
clientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// shopsToolStripMenuItem
|
// shopsToolStripMenuItem
|
||||||
//
|
//
|
||||||
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
shopsToolStripMenuItem.Name = "shopsToolStripMenuItem";
|
||||||
shopsToolStripMenuItem.Size = new Size(180, 22);
|
shopsToolStripMenuItem.Size = new Size(149, 22);
|
||||||
shopsToolStripMenuItem.Text = "Магазины";
|
shopsToolStripMenuItem.Text = "Магазины";
|
||||||
shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
shopsToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// исполнителиToolStripMenuItem1
|
||||||
|
//
|
||||||
|
исполнителиToolStripMenuItem1.Name = "исполнителиToolStripMenuItem1";
|
||||||
|
исполнителиToolStripMenuItem1.Size = new Size(149, 22);
|
||||||
|
исполнителиToolStripMenuItem1.Text = "Исполнители";
|
||||||
|
исполнителиToolStripMenuItem1.Click += ImplementersToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// reportToolStripMenuItem
|
// reportToolStripMenuItem
|
||||||
//
|
//
|
||||||
reportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listDishesToolStripMenuItem, componentDishToolStripMenuItem, listOrdersToolStripMenuItem, listShopsToolStripMenuItem, shopDishToolStripMenuItem, listOrderToDateToolStripMenuItem });
|
reportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listDishesToolStripMenuItem, componentDishToolStripMenuItem, listOrdersToolStripMenuItem, listShopsToolStripMenuItem, shopDishToolStripMenuItem, listOrderToDateToolStripMenuItem });
|
||||||
@ -177,7 +186,7 @@
|
|||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
buttonUpdate.Location = new Point(780, 230);
|
buttonUpdate.Location = new Point(962, 244);
|
||||||
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
|
buttonUpdate.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(170, 58);
|
buttonUpdate.Size = new Size(170, 58);
|
||||||
@ -188,7 +197,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCreateOrder
|
// buttonCreateOrder
|
||||||
//
|
//
|
||||||
buttonCreateOrder.Location = new Point(780, 66);
|
buttonCreateOrder.Location = new Point(962, 70);
|
||||||
buttonCreateOrder.Margin = new Padding(3, 2, 3, 2);
|
buttonCreateOrder.Margin = new Padding(3, 2, 3, 2);
|
||||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||||
buttonCreateOrder.Size = new Size(170, 58);
|
buttonCreateOrder.Size = new Size(170, 58);
|
||||||
@ -206,13 +215,13 @@
|
|||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 29;
|
dataGridView.RowTemplate.Height = 29;
|
||||||
dataGridView.Size = new Size(755, 426);
|
dataGridView.Size = new Size(956, 426);
|
||||||
dataGridView.TabIndex = 7;
|
dataGridView.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// buttonAddDishInShop
|
// buttonAddDishInShop
|
||||||
//
|
//
|
||||||
buttonAddDishInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonAddDishInShop.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonAddDishInShop.Location = new Point(780, 377);
|
buttonAddDishInShop.Location = new Point(962, 327);
|
||||||
buttonAddDishInShop.Name = "buttonAddDishInShop";
|
buttonAddDishInShop.Name = "buttonAddDishInShop";
|
||||||
buttonAddDishInShop.Size = new Size(170, 61);
|
buttonAddDishInShop.Size = new Size(170, 61);
|
||||||
buttonAddDishInShop.TabIndex = 13;
|
buttonAddDishInShop.TabIndex = 13;
|
||||||
@ -227,11 +236,23 @@
|
|||||||
исполнителиToolStripMenuItem.Text = "Исполнители";
|
исполнителиToolStripMenuItem.Text = "Исполнители";
|
||||||
исполнителиToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
исполнителиToolStripMenuItem.Click += ImplementersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// buttonSetToFinish
|
||||||
|
//
|
||||||
|
buttonSetToFinish.Location = new Point(962, 156);
|
||||||
|
buttonSetToFinish.Margin = new Padding(3, 2, 3, 2);
|
||||||
|
buttonSetToFinish.Name = "buttonSetToFinish";
|
||||||
|
buttonSetToFinish.Size = new Size(170, 58);
|
||||||
|
buttonSetToFinish.TabIndex = 14;
|
||||||
|
buttonSetToFinish.Text = "Заказ выдан";
|
||||||
|
buttonSetToFinish.UseVisualStyleBackColor = true;
|
||||||
|
buttonSetToFinish.Click += ButtonIssuedOrder_Click;
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(975, 450);
|
ClientSize = new Size(1157, 450);
|
||||||
|
Controls.Add(buttonSetToFinish);
|
||||||
Controls.Add(buttonAddDishInShop);
|
Controls.Add(buttonAddDishInShop);
|
||||||
Controls.Add(buttonUpdate);
|
Controls.Add(buttonUpdate);
|
||||||
Controls.Add(buttonCreateOrder);
|
Controls.Add(buttonCreateOrder);
|
||||||
@ -273,5 +294,7 @@
|
|||||||
private ToolStripMenuItem ClientToolStripMenuItem;
|
private ToolStripMenuItem ClientToolStripMenuItem;
|
||||||
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
private ToolStripMenuItem исполнителиToolStripMenuItem;
|
||||||
private ToolStripMenuItem DoWorkToolStripMenuItem;
|
private ToolStripMenuItem DoWorkToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem исполнителиToolStripMenuItem1;
|
||||||
|
private Button buttonSetToFinish;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -95,9 +95,13 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (model.DishId < 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Некорректный идентификатор у блюда", nameof(model.DishId));
|
||||||
|
}
|
||||||
if (model.Id < 0)
|
if (model.Id < 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Некорректный идентификатор у продукта", nameof(model.Id));
|
throw new ArgumentNullException("Некорректный идентификатор у заказа", nameof(model.Id));
|
||||||
}
|
}
|
||||||
if (model.ClientId < 0)
|
if (model.ClientId < 0)
|
||||||
{
|
{
|
||||||
@ -121,7 +125,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(model));
|
throw new ArgumentNullException(nameof(model));
|
||||||
}
|
}
|
||||||
if (viewModel.Status + 1 != newStatus)
|
if (viewModel.Status + 1 != newStatus && viewModel.Status != OrderStatus.Ожидание)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("Change status operation failed");
|
_logger.LogWarning("Change status operation failed");
|
||||||
return false;
|
return false;
|
||||||
@ -131,18 +135,22 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
model.ImplementerId = viewModel.ImplementerId;
|
model.ImplementerId = viewModel.ImplementerId;
|
||||||
}
|
}
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
if (model.Status == OrderStatus.Готов)
|
if (model.Status == OrderStatus.Готов || viewModel.Status == OrderStatus.Ожидание)
|
||||||
{
|
{
|
||||||
model.DateImplement = DateTime.Now;
|
if (!_logicS.AddDishes(_dishStorage.GetElement(new DishSearchModel { Id = viewModel.DishId })!, viewModel.Count))
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Ожидание;
|
||||||
|
_logger.LogWarning("В магазинах нет места под автомобили из заказа.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
model.DateImplement = viewModel.DateImplement;
|
model.DateImplement = viewModel.DateImplement;
|
||||||
}
|
}
|
||||||
if (model.Status == OrderStatus.Выдан && !_logicS.AddDishes(_dishStorage.GetElement(new DishSearchModel { Id = viewModel.DishId })!, viewModel.Count))
|
|
||||||
{
|
|
||||||
throw new Exception("В магазинах нет места под блюда из заказа.");
|
|
||||||
}
|
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
if (_orderStorage.Update(model) == null)
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
|
@ -167,6 +167,10 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
foreach (ShopViewModel shop in shopsList)
|
foreach (ShopViewModel shop in shopsList)
|
||||||
{
|
{
|
||||||
int emptySpace = shop.Capacity - shop.ShopDishes.Sum(x => x.Value.Item2);
|
int emptySpace = shop.Capacity - shop.ShopDishes.Sum(x => x.Value.Item2);
|
||||||
|
if (emptySpace <= 0)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (emptySpace < count)
|
if (emptySpace < count)
|
||||||
{
|
{
|
||||||
DeliveryDishes(new ShopSearchModel { Id = shop.Id }, dish, emptySpace);
|
DeliveryDishes(new ShopSearchModel { Id = shop.Id }, dish, emptySpace);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using FoodOrdersContracts.BindingModels;
|
using DocumentFormat.OpenXml.EMMA;
|
||||||
|
using FoodOrdersContracts.BindingModels;
|
||||||
using FoodOrdersContracts.BusinessLogicsContracts;
|
using FoodOrdersContracts.BusinessLogicsContracts;
|
||||||
using FoodOrdersContracts.SearchModels;
|
using FoodOrdersContracts.SearchModels;
|
||||||
using FoodOrdersContracts.ViewModels;
|
using FoodOrdersContracts.ViewModels;
|
||||||
@ -33,8 +34,16 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
||||||
if (orders == null || orders.Count == 0)
|
if (orders == null || orders.Count == 0)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
var waitingOrders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Ожидание });
|
||||||
return;
|
if (waitingOrders == null || waitingOrders.Count == 0)
|
||||||
|
{
|
||||||
|
var relatedOrders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выполняется });
|
||||||
|
if (relatedOrders == null || relatedOrders.Count == 0)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
_logger.LogDebug("DoWork for {Count} orders", orders.Count);
|
||||||
foreach (var implementer in implementers)
|
foreach (var implementer in implementers)
|
||||||
@ -54,6 +63,7 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await RunExpectationInWork(implementer);
|
||||||
await RunOrderInWork(implementer);
|
await RunOrderInWork(implementer);
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
@ -69,6 +79,10 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
Id = order.Id,
|
Id = order.Id,
|
||||||
ImplementerId = implementer.Id
|
ImplementerId = implementer.Id
|
||||||
});
|
});
|
||||||
|
if (_orderLogic.ReadElement(new OrderSearchModel { Id = order.Id })!.Status == OrderStatus.Ожидание)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
// делаем работу
|
// делаем работу
|
||||||
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 1000) * order.Count);
|
||||||
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, order.Id);
|
||||||
@ -141,5 +155,45 @@ namespace FoodOrdersBusinessLogic.BusinessLogics
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private async Task RunExpectationInWork(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var expectOrder = await Task.Run(() => _orderLogic.ReadElement(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Ожидание
|
||||||
|
}));
|
||||||
|
if (expectOrder == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} back to order {Order}", implementer.Id, expectOrder.Id);
|
||||||
|
// доделываем работу
|
||||||
|
Thread.Sleep(implementer.WorkExperience * _rnd.Next(100, 300) * expectOrder.Count);
|
||||||
|
_logger.LogDebug("DoWork. Worker {Id} finish order {Order}", implementer.Id, expectOrder.Id);
|
||||||
|
_orderLogic.FinishOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = expectOrder.Id
|
||||||
|
});
|
||||||
|
// отдыхаем
|
||||||
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
|
}
|
||||||
|
// заказа может не быть, просто игнорируем ошибку
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try get work");
|
||||||
|
}
|
||||||
|
// а может возникнуть иная ошибка, тогда просто заканчиваем выполнение имитации
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,6 +6,7 @@
|
|||||||
Принят = 0,
|
Принят = 0,
|
||||||
Выполняется = 1,
|
Выполняется = 1,
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
Выдан = 3
|
Выдан = 3,
|
||||||
|
Ожидание = 3
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,7 +9,7 @@ namespace FoodOrdersDatabaseImplement
|
|||||||
{
|
{
|
||||||
if (optionsBuilder.IsConfigured == false)
|
if (optionsBuilder.IsConfigured == false)
|
||||||
{
|
{
|
||||||
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-SINQU55\SQLEXPRESS;Initial Catalog=FoodOrdersDatabase1;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
optionsBuilder.UseSqlServer(@"Data Source=DESKTOP-SINQU55\SQLEXPRESS;Initial Catalog=FoodOrdersDatabaseh6;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||||
}
|
}
|
||||||
base.OnConfiguring(optionsBuilder);
|
base.OnConfiguring(optionsBuilder);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ using FoodOrdersContracts.StoragesContracts;
|
|||||||
using FoodOrdersContracts.ViewModels;
|
using FoodOrdersContracts.ViewModels;
|
||||||
using FoodOrdersDatabaseImplement.Models;
|
using FoodOrdersDatabaseImplement.Models;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace FoodOrdersDatabaseImplement.Implements
|
namespace FoodOrdersDatabaseImplement.Implements
|
||||||
{
|
{
|
||||||
@ -68,17 +69,26 @@ namespace FoodOrdersDatabaseImplement.Implements
|
|||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
using var context = new FoodOrdersDatabase();
|
using var context = new FoodOrdersDatabase();
|
||||||
return context.Orders
|
if (model.Id.HasValue)
|
||||||
.Include(x => x.Dish)
|
{
|
||||||
.Include(x => x.Client)
|
return context.Orders
|
||||||
.Include(x => x.Implementer)
|
.Include(x => x.Dish)
|
||||||
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
.Include(x => x.Client)
|
||||||
?.GetViewModel;
|
.Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
else if (model.Status.HasValue && model.ImplementerId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Dish)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Include(x => x.Implementer)
|
||||||
|
.FirstOrDefault(x => x.ImplementerId == model.ImplementerId && x.Status == model.Status)
|
||||||
|
?.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
|
334
FoodOrders/FoodOrdersDatabaseImplement/Migrations/20230421140449_h6.Designer.cs
generated
Normal file
334
FoodOrders/FoodOrdersDatabaseImplement/Migrations/20230421140449_h6.Designer.cs
generated
Normal file
@ -0,0 +1,334 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FoodOrdersDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FoodOrdersDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(FoodOrdersDatabase))]
|
||||||
|
[Migration("20230421140449_h6")]
|
||||||
|
partial class h6
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("DishName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Dishes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.ToTable("DishComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Capacity")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateOfOpening")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.ToTable("ShopDishes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("DishComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Dishes")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DishComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Dishes");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,244 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FoodOrdersDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class h6 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Clients",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Clients", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Components",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Cost = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Components", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Dishes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
DishName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Price = table.Column<double>(type: "float", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Dishes", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Implementers",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ImplementerFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
WorkExperience = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Qualification = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Implementers", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Shops",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShopName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
Address = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||||
|
DateOfOpening = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
Capacity = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Shops", x => x.Id);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "DishComponents",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
DishId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_DishComponents", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_DishComponents_Components_ComponentId",
|
||||||
|
column: x => x.ComponentId,
|
||||||
|
principalTable: "Components",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_DishComponents_Dishes_DishId",
|
||||||
|
column: x => x.DishId,
|
||||||
|
principalTable: "Dishes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "Orders",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
DishId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Sum = table.Column<double>(type: "float", nullable: false),
|
||||||
|
Status = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||||
|
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_Orders", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Clients_ClientId",
|
||||||
|
column: x => x.ClientId,
|
||||||
|
principalTable: "Clients",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Dishes_DishId",
|
||||||
|
column: x => x.DishId,
|
||||||
|
principalTable: "Dishes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
column: x => x.ImplementerId,
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "Id");
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "ShopDishes",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
|
ShopId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
DishId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
Count = table.Column<int>(type: "int", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_ShopDishes", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopDishes_Dishes_DishId",
|
||||||
|
column: x => x.DishId,
|
||||||
|
principalTable: "Dishes",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_ShopDishes_Shops_ShopId",
|
||||||
|
column: x => x.ShopId,
|
||||||
|
principalTable: "Shops",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_DishComponents_ComponentId",
|
||||||
|
table: "DishComponents",
|
||||||
|
column: "ComponentId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_DishComponents_DishId",
|
||||||
|
table: "DishComponents",
|
||||||
|
column: "DishId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ClientId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_DishId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "DishId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopDishes_DishId",
|
||||||
|
table: "ShopDishes",
|
||||||
|
column: "DishId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_ShopDishes_ShopId",
|
||||||
|
table: "ShopDishes",
|
||||||
|
column: "ShopId");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "DishComponents");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Orders");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "ShopDishes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Components");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Clients");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Dishes");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Shops");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,331 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using FoodOrdersDatabaseImplement;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace FoodOrdersDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(FoodOrdersDatabase))]
|
||||||
|
partial class FoodOrdersDatabaseModelSnapshot : ModelSnapshot
|
||||||
|
{
|
||||||
|
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.3")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||||
|
|
||||||
|
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ClientFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Email")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ComponentName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Cost")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("DishName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Dishes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.ToTable("DishComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("ImplementerFIO")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<string>("Password")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Qualification")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("WorkExperience")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Implementers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateCreate")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("DateImplement")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("Status")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<double>("Sum")
|
||||||
|
.HasColumnType("float");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.Property<int>("Capacity")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<DateTime>("DateOfOpening")
|
||||||
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<string>("ShopName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("nvarchar(max)");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Shops");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("DishId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<int>("ShopId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("DishId");
|
||||||
|
|
||||||
|
b.HasIndex("ShopId");
|
||||||
|
|
||||||
|
b.ToTable("ShopDishes");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.DishComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("DishComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Orders")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.ShopDish", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Dish", "Dish")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("DishId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("FoodOrdersDatabaseImplement.Models.Shop", "Shop")
|
||||||
|
.WithMany("Dishes")
|
||||||
|
.HasForeignKey("ShopId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Dish");
|
||||||
|
|
||||||
|
b.Navigation("Shop");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("DishComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Dish", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("FoodOrdersDatabaseImplement.Models.Shop", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Dishes");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user