lab6hard
This commit is contained in:
parent
33f57f1dcc
commit
60dbd3137f
@ -78,24 +78,30 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
}
|
}
|
||||||
public bool DeliveryOrder(OrderBindingModel model)
|
public bool DeliveryOrder(OrderBindingModel model)
|
||||||
{
|
{
|
||||||
var order = _orderStorage.GetElement(new OrderSearchModel
|
lock (_locker)
|
||||||
{
|
{
|
||||||
Id = model.Id,
|
model = FillOrderBindingModel(model);
|
||||||
});
|
if (model.Status != OrderStatus.Готов && model.Status != OrderStatus.Ожидает)
|
||||||
if (order == null)
|
{
|
||||||
{
|
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-Выдан.", model.Status);
|
||||||
throw new ArgumentNullException(nameof(order));
|
throw new InvalidOperationException($"Невозможно приствоить статус выдан заказу с текущим статусом {model.Status}");
|
||||||
|
}
|
||||||
|
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
||||||
|
{
|
||||||
|
PizzaId = model.PizzaId,
|
||||||
|
Count = model.Count
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
if (model.Status == OrderStatus.Готов)
|
||||||
|
{
|
||||||
|
model.Status = OrderStatus.Ожидает;
|
||||||
|
UpdateOrder(model);
|
||||||
|
}
|
||||||
|
throw new ArgumentException("Недостаточно места в магазинах для поставки");
|
||||||
|
}
|
||||||
|
model.Status = OrderStatus.Выдан;
|
||||||
|
return UpdateOrder(model);
|
||||||
}
|
}
|
||||||
if (!_shopStorage.RestockingShops(new SupplyBindingModel
|
|
||||||
{
|
|
||||||
PizzaId = order.PizzaId,
|
|
||||||
Count = order.Count
|
|
||||||
}))
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Недостаточно места");
|
|
||||||
}
|
|
||||||
|
|
||||||
return ChangeStatus(model, OrderStatus.Выдан);
|
|
||||||
}
|
}
|
||||||
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
private void CheckModel(OrderBindingModel model, bool withParams = true)
|
||||||
{
|
{
|
||||||
@ -123,38 +129,52 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
model.PizzaId, model.Count,model.Sum, model.Id);
|
model.PizzaId, model.Count,model.Sum, model.Id);
|
||||||
}
|
}
|
||||||
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
|
private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) {
|
||||||
|
model = FillOrderBindingModel(model);
|
||||||
|
|
||||||
|
if (requiredStatus - model.Status == 1)
|
||||||
|
{
|
||||||
|
model.Status = requiredStatus;
|
||||||
|
if (model.Status == OrderStatus.Готов)
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
return UpdateOrder(model);
|
||||||
|
}
|
||||||
|
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
||||||
|
throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private OrderBindingModel FillOrderBindingModel(OrderBindingModel model)
|
||||||
|
{
|
||||||
CheckModel(model, false);
|
CheckModel(model, false);
|
||||||
var element = _orderStorage.GetElement(new OrderSearchModel()
|
var element = _orderStorage.GetElement(new OrderSearchModel()
|
||||||
{
|
{
|
||||||
Id = model.Id
|
Id = model.Id
|
||||||
});
|
});
|
||||||
if(element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(nameof(element));
|
throw new InvalidOperationException(nameof(element));
|
||||||
}
|
}
|
||||||
|
model.Id = element.Id;
|
||||||
model.DateCreate = element.DateCreate;
|
model.DateCreate = element.DateCreate;
|
||||||
model.PizzaId = element.PizzaId;
|
model.PizzaId = element.PizzaId;
|
||||||
model.DateImplement = element.DateImplement;
|
model.DateImplement = element.DateImplement;
|
||||||
model.ClientId = element.ClientId;
|
model.ClientId = element.ClientId;
|
||||||
if (!model.ImplementerId.HasValue)
|
|
||||||
model.ImplementerId = element.ImplementerId;
|
|
||||||
model.Status = element.Status;
|
model.Status = element.Status;
|
||||||
model.Count = element.Count;
|
model.Count = element.Count;
|
||||||
model.Sum = element.Sum;
|
model.Sum = element.Sum;
|
||||||
if(requiredStatus - model.Status == 1)
|
if (!model.ImplementerId.HasValue)
|
||||||
|
model.ImplementerId = element.ImplementerId;
|
||||||
|
return model;
|
||||||
|
}
|
||||||
|
private bool UpdateOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
if (_orderStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
model.Status = requiredStatus;
|
_logger.LogWarning("Update operation failed");
|
||||||
if(model.Status == OrderStatus.Готов)
|
return false;
|
||||||
model.DateImplement = DateTime.Now;
|
|
||||||
if (_orderStorage.Update(model) == null)
|
|
||||||
{
|
|
||||||
_logger.LogWarning("Update operation failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
_logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus);
|
_logger.LogWarning("Update operation sucsess");
|
||||||
throw new InvalidOperationException($"Невозможно приствоить статус {requiredStatus} заказу с текущим статусом {model.Status}");
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,8 +35,9 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
_logger.LogWarning("DoWork. Implementers is null");
|
_logger.LogWarning("DoWork. Implementers is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Принят });
|
var orders = _orderLogic.ReadList(new OrderSearchModel { Status = OrderStatus.Выдан });
|
||||||
if (orders == null || orders.Count == 0)
|
int count = _orderLogic.ReadList(new OrderSearchModel()).Count;
|
||||||
|
if (orders == null || count == orders.Count)
|
||||||
{
|
{
|
||||||
_logger.LogWarning("DoWork. Orders is null or empty");
|
_logger.LogWarning("DoWork. Orders is null or empty");
|
||||||
return;
|
return;
|
||||||
@ -59,6 +60,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await DeliverWaitingOrder(implementer);
|
||||||
await RunOrderInWork(implementer);
|
await RunOrderInWork(implementer);
|
||||||
|
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
@ -81,6 +83,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
Id = order.Id
|
Id = order.Id
|
||||||
});
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = order.Id });
|
||||||
}
|
}
|
||||||
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
// кто-то мог уже перехватить заказ, игнорируем ошибку
|
||||||
catch (InvalidOperationException ex)
|
catch (InvalidOperationException ex)
|
||||||
@ -130,6 +133,7 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
Id = runOrder.Id
|
Id = runOrder.Id
|
||||||
});
|
});
|
||||||
|
_orderLogic.DeliveryOrder(new OrderBindingModel { Id = runOrder.Id });
|
||||||
// отдыхаем
|
// отдыхаем
|
||||||
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
Thread.Sleep(implementer.Qualification * _rnd.Next(10, 100));
|
||||||
}
|
}
|
||||||
@ -145,5 +149,47 @@ namespace PizzeriaBusinessLogic.BusinessLogics
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task DeliverWaitingOrder(ImplementerViewModel implementer)
|
||||||
|
{
|
||||||
|
if (_orderLogic == null || implementer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var waitingOrders = await Task.Run(() => _orderLogic.ReadList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ImplementerId = implementer.Id,
|
||||||
|
Status = OrderStatus.Ожидает
|
||||||
|
})) ;
|
||||||
|
if (waitingOrders == null || waitingOrders.Count == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Find some waitig order for implementer:{id}.Count:{count}", implementer.Id, waitingOrders.Count);
|
||||||
|
foreach (var waitingOrder in waitingOrders)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_logger.LogInformation("DeliverWaitingOrder. Trying to deliver order id:{id}", waitingOrder.Id);
|
||||||
|
var res = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = waitingOrder.Id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
catch (ArgumentException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "DeliverWaitingOrder. Fault");
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
_logger.LogWarning(ex, "Error try deliver order");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error while do work");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ namespace PizzeriaDataModels.Enums
|
|||||||
Принят = 0,
|
Принят = 0,
|
||||||
Выполняется = 1,
|
Выполняется = 1,
|
||||||
Готов = 2,
|
Готов = 2,
|
||||||
Выдан = 3
|
Ожидает = 3,
|
||||||
|
Выдан = 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,266 +0,0 @@
|
|||||||
// <auto-generated />
|
|
||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
using PizzeriaDatabaseImplement;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PizzeriaDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(PizzeriaDatabase))]
|
|
||||||
[Migration("20230418063952_implementors")]
|
|
||||||
partial class implementors
|
|
||||||
{
|
|
||||||
/// <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("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.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?>("ImplementerId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("PizzaId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Status")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<double>("Sum")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("ImplementerId");
|
|
||||||
|
|
||||||
b.HasIndex("PizzaId");
|
|
||||||
|
|
||||||
b.ToTable("Orders");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("PizzaName")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<double>("Price")
|
|
||||||
.HasColumnType("float");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Pizzas");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.PizzaComponent", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<int?>("ClientId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("ComponentId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Count")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("PizzaId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.HasIndex("ClientId");
|
|
||||||
|
|
||||||
b.HasIndex("ComponentId");
|
|
||||||
|
|
||||||
b.HasIndex("PizzaId");
|
|
||||||
|
|
||||||
b.ToTable("PizzaComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Client", "Client")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("ClientId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Implementer", "Implementer")
|
|
||||||
.WithMany("Order")
|
|
||||||
.HasForeignKey("ImplementerId");
|
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
|
||||||
.WithMany("Orders")
|
|
||||||
.HasForeignKey("PizzaId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Client");
|
|
||||||
|
|
||||||
b.Navigation("Implementer");
|
|
||||||
|
|
||||||
b.Navigation("Pizza");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.PizzaComponent", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Client", null)
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("ClientId");
|
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Component", "Component")
|
|
||||||
.WithMany("PizzaComponents")
|
|
||||||
.HasForeignKey("ComponentId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
|
||||||
.WithMany("Components")
|
|
||||||
.HasForeignKey("PizzaId")
|
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
|
||||||
.IsRequired();
|
|
||||||
|
|
||||||
b.Navigation("Component");
|
|
||||||
|
|
||||||
b.Navigation("Pizza");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Client", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Component", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("PizzaComponents");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Implementer", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Order");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
|
||||||
{
|
|
||||||
b.Navigation("Components");
|
|
||||||
|
|
||||||
b.Navigation("Orders");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,196 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace PizzeriaDatabaseImplement.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class implementors : 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: "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: "Pizzas",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
PizzaName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Price = table.Column<double>(type: "float", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Pizzas", x => x.Id);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Orders",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
PizzaId = 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_Implementers_ImplementerId",
|
|
||||||
column: x => x.ImplementerId,
|
|
||||||
principalTable: "Implementers",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_Orders_Pizzas_PizzaId",
|
|
||||||
column: x => x.PizzaId,
|
|
||||||
principalTable: "Pizzas",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "PizzaComponents",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
PizzaId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ClientId = table.Column<int>(type: "int", nullable: true)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_PizzaComponents", x => x.Id);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PizzaComponents_Clients_ClientId",
|
|
||||||
column: x => x.ClientId,
|
|
||||||
principalTable: "Clients",
|
|
||||||
principalColumn: "Id");
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PizzaComponents_Components_ComponentId",
|
|
||||||
column: x => x.ComponentId,
|
|
||||||
principalTable: "Components",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
table.ForeignKey(
|
|
||||||
name: "FK_PizzaComponents_Pizzas_PizzaId",
|
|
||||||
column: x => x.PizzaId,
|
|
||||||
principalTable: "Pizzas",
|
|
||||||
principalColumn: "Id",
|
|
||||||
onDelete: ReferentialAction.Cascade);
|
|
||||||
});
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ClientId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ClientId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_ImplementerId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "ImplementerId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_Orders_PizzaId",
|
|
||||||
table: "Orders",
|
|
||||||
column: "PizzaId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PizzaComponents_ClientId",
|
|
||||||
table: "PizzaComponents",
|
|
||||||
column: "ClientId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PizzaComponents_ComponentId",
|
|
||||||
table: "PizzaComponents",
|
|
||||||
column: "ComponentId");
|
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
|
||||||
name: "IX_PizzaComponents_PizzaId",
|
|
||||||
table: "PizzaComponents",
|
|
||||||
column: "PizzaId");
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Orders");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "PizzaComponents");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Implementers");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Clients");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Components");
|
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Pizzas");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -12,7 +12,7 @@ using PizzeriaDatabaseImplement;
|
|||||||
namespace PizzeriaDatabaseImplement.Migrations
|
namespace PizzeriaDatabaseImplement.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(PizzeriaDatabase))]
|
[DbContext(typeof(PizzeriaDatabase))]
|
||||||
[Migration("20230503183159_init")]
|
[Migration("20230503204906_init")]
|
||||||
partial class init
|
partial class init
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -70,6 +70,33 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -90,6 +117,9 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("PizzaId")
|
b.Property<int>("PizzaId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -103,6 +133,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.HasIndex("PizzaId");
|
b.HasIndex("PizzaId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -220,6 +252,10 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Order")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("PizzaId")
|
.HasForeignKey("PizzaId")
|
||||||
@ -228,6 +264,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Pizza");
|
b.Navigation("Pizza");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -283,6 +321,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Navigation("PizzaComponents");
|
b.Navigation("PizzaComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Order");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
@ -40,6 +40,22 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
table.PrimaryKey("PK_Components", x => x.Id);
|
table.PrimaryKey("PK_Components", 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(
|
migrationBuilder.CreateTable(
|
||||||
name: "Pizzas",
|
name: "Pizzas",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
@ -78,6 +94,7 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
.Annotation("SqlServer:Identity", "1, 1"),
|
||||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||||
PizzaId = table.Column<int>(type: "int", nullable: false),
|
PizzaId = table.Column<int>(type: "int", nullable: false),
|
||||||
|
ImplementerId = table.Column<int>(type: "int", nullable: true),
|
||||||
Count = table.Column<int>(type: "int", nullable: false),
|
Count = table.Column<int>(type: "int", nullable: false),
|
||||||
Sum = table.Column<double>(type: "float", nullable: false),
|
Sum = table.Column<double>(type: "float", nullable: false),
|
||||||
Status = table.Column<int>(type: "int", nullable: false),
|
Status = table.Column<int>(type: "int", nullable: false),
|
||||||
@ -93,6 +110,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
principalTable: "Clients",
|
principalTable: "Clients",
|
||||||
principalColumn: "Id",
|
principalColumn: "Id",
|
||||||
onDelete: ReferentialAction.Cascade);
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_Orders_Implementers_ImplementerId",
|
||||||
|
column: x => x.ImplementerId,
|
||||||
|
principalTable: "Implementers",
|
||||||
|
principalColumn: "Id");
|
||||||
table.ForeignKey(
|
table.ForeignKey(
|
||||||
name: "FK_Orders_Pizzas_PizzaId",
|
name: "FK_Orders_Pizzas_PizzaId",
|
||||||
column: x => x.PizzaId,
|
column: x => x.PizzaId,
|
||||||
@ -166,6 +188,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
table: "Orders",
|
table: "Orders",
|
||||||
column: "ClientId");
|
column: "ClientId");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Orders_ImplementerId",
|
||||||
|
table: "Orders",
|
||||||
|
column: "ImplementerId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
migrationBuilder.CreateIndex(
|
||||||
name: "IX_Orders_PizzaId",
|
name: "IX_Orders_PizzaId",
|
||||||
table: "Orders",
|
table: "Orders",
|
||||||
@ -209,6 +236,9 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "ShopPizzas");
|
name: "ShopPizzas");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "Implementers");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Clients");
|
name: "Clients");
|
||||||
|
|
@ -67,6 +67,33 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.ToTable("Components");
|
b.ToTable("Components");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.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("PizzeriaDatabaseImplement.Models.Order", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Order", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@ -87,6 +114,9 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime?>("DateImplement")
|
b.Property<DateTime?>("DateImplement")
|
||||||
.HasColumnType("datetime2");
|
.HasColumnType("datetime2");
|
||||||
|
|
||||||
|
b.Property<int?>("ImplementerId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
b.Property<int>("PizzaId")
|
b.Property<int>("PizzaId")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@ -100,6 +130,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.HasIndex("ClientId");
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.HasIndex("ImplementerId");
|
||||||
|
|
||||||
b.HasIndex("PizzaId");
|
b.HasIndex("PizzaId");
|
||||||
|
|
||||||
b.ToTable("Orders");
|
b.ToTable("Orders");
|
||||||
@ -217,6 +249,10 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("PizzeriaDatabaseImplement.Models.Implementer", "Implementer")
|
||||||
|
.WithMany("Order")
|
||||||
|
.HasForeignKey("ImplementerId");
|
||||||
|
|
||||||
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
b.HasOne("PizzeriaDatabaseImplement.Models.Pizza", "Pizza")
|
||||||
.WithMany("Orders")
|
.WithMany("Orders")
|
||||||
.HasForeignKey("PizzaId")
|
.HasForeignKey("PizzaId")
|
||||||
@ -225,6 +261,8 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
|
|
||||||
b.Navigation("Client");
|
b.Navigation("Client");
|
||||||
|
|
||||||
|
b.Navigation("Implementer");
|
||||||
|
|
||||||
b.Navigation("Pizza");
|
b.Navigation("Pizza");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -280,6 +318,11 @@ namespace PizzeriaDatabaseImplement.Migrations
|
|||||||
b.Navigation("PizzaComponents");
|
b.Navigation("PizzaComponents");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Implementer", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Order");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
modelBuilder.Entity("PizzeriaDatabaseImplement.Models.Pizza", b =>
|
||||||
{
|
{
|
||||||
b.Navigation("Components");
|
b.Navigation("Components");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user