Remade database, clients can now create purchases and components
This commit is contained in:
parent
b628efed1a
commit
29dd3e6dd9
@ -61,17 +61,17 @@ namespace ComputerShopBusinessLogic.BusinessLogics
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool TakeOrderInWork(PurchaseBindingModel model)
|
||||
public bool TakePurchaseInWork(PurchaseBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, PurchaseStatus.Выполняется);
|
||||
}
|
||||
|
||||
public bool DeliveryOrder(PurchaseBindingModel model)
|
||||
public bool DeliveryPurchase(PurchaseBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, PurchaseStatus.Готов);
|
||||
}
|
||||
|
||||
public bool FinishOrder(PurchaseBindingModel model)
|
||||
public bool FinishPurchase(PurchaseBindingModel model)
|
||||
{
|
||||
return StatusUpdate(model, PurchaseStatus.Выдан);
|
||||
}
|
||||
|
@ -24,6 +24,15 @@ namespace ComputerShopClientApp.Controllers
|
||||
return View(APIClient.GetRequest<List<PurchaseViewModel>>($"api/main/getpurchases?clientId={APIClient.Client.Id}"));
|
||||
}
|
||||
|
||||
public IActionResult Component()
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<ComponentViewModel>>($"api/component/getcomponentlist"));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Privacy()
|
||||
{
|
||||
@ -110,14 +119,14 @@ namespace ComputerShopClientApp.Controllers
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult Create()
|
||||
public IActionResult CreatePurchase()
|
||||
{
|
||||
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist");
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public void Create(int component, int count)
|
||||
public void CreatePurchase(int component, int count)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
@ -137,6 +146,33 @@ namespace ComputerShopClientApp.Controllers
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateComponent()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateComponent(string name, int cost)
|
||||
{
|
||||
if (APIClient.Client == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
if (cost <= 0)
|
||||
{
|
||||
throw new Exception("Цена должна быть больше 0");
|
||||
}
|
||||
APIClient.PostRequest("api/component/createcomponent", new ComponentBindingModel
|
||||
{
|
||||
ClientId = APIClient.Client.Id,
|
||||
ComponentName = name,
|
||||
Cost = cost
|
||||
});
|
||||
Response.Redirect("Index");
|
||||
}
|
||||
|
||||
|
||||
|
||||
[HttpPost]
|
||||
public double Calc(int count, int component)
|
||||
{
|
||||
|
@ -0,0 +1,57 @@
|
||||
@using ComputerShopContracts.ViewModels
|
||||
|
||||
@model List<ComponentViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Component";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Компоненты</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="CreateComponent">Создать комплектующее</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Компонент
|
||||
</th>
|
||||
<th>
|
||||
Цена
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ComponentName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Cost)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -0,0 +1,20 @@
|
||||
@{
|
||||
ViewData["Title"] = "CreateComponent";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание комплектующего</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8"><input type="text" name="name" id="name" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена:</div>
|
||||
<div class="col-8"><input type="text" name="cost" id="cost" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Создать" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,5 +1,5 @@
|
||||
@{
|
||||
ViewData["Title"] = "Create";
|
||||
ViewData["Title"] = "CreatePurchase";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
@ -20,7 +20,7 @@
|
||||
}
|
||||
|
||||
<p>
|
||||
<a asp-action="Create">Создать заказ</a>
|
||||
<a asp-action="CreatePurchase">Создать заказ</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
|
@ -13,31 +13,27 @@
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<div class="container">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-
|
||||
action="Index">Магазин компьютерной техники</a>
|
||||
<button class="navbar-toggler" type="button" data-
|
||||
toggle="collapse" data-target=".navbar-collapse" aria-
|
||||
controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин компьютерной техники</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-
|
||||
area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-
|
||||
area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Component">Компоненты</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-
|
||||
area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-
|
||||
area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
@ -12,5 +12,6 @@ namespace ComputerShopContracts.BindingModels
|
||||
public int Id { get; set; }
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
public double Cost { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -13,8 +13,8 @@ namespace ComputerShopContracts.BusinessLogicContracts
|
||||
{
|
||||
List<PurchaseViewModel>? ReadList(PurchaseSearchModel? model);
|
||||
bool CreatePurchase(PurchaseBindingModel model);
|
||||
bool TakeOrderInWork(PurchaseBindingModel model);
|
||||
bool FinishOrder(PurchaseBindingModel model);
|
||||
bool DeliveryOrder(PurchaseBindingModel model);
|
||||
bool TakePurchaseInWork(PurchaseBindingModel model);
|
||||
bool FinishPurchase(PurchaseBindingModel model);
|
||||
bool DeliveryPurchase(PurchaseBindingModel model);
|
||||
}
|
||||
}
|
||||
|
@ -15,5 +15,9 @@ namespace ComputerShopContracts.ViewModels
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Цена")]
|
||||
public double Cost { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,10 @@ namespace ComputerShopContracts.ViewModels
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
public int ClientId { get; set; }
|
||||
|
||||
[DisplayName("ФИО клиента")]
|
||||
public string ClientFIO { get; set; } = string.Empty;
|
||||
[DisplayName("Сумма")]
|
||||
public double Sum { get; set; }
|
||||
[DisplayName("Статус")]
|
||||
|
@ -26,11 +26,19 @@ namespace ComputerShopDatabaseImplement.Implements
|
||||
|
||||
public List<PurchaseViewModel> GetFilteredList(PurchaseSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue && !model.ClientId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new ComputerShopDatabase();
|
||||
if (model.ClientId.HasValue)
|
||||
{
|
||||
return context.Purchases
|
||||
.Include(x => x.Client)
|
||||
.Where(x => x.ClientId == model.ClientId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return context.Purchases
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Include(x => x.Component)
|
||||
|
@ -1,414 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerShopDatabase))]
|
||||
[Migration("20230407125028_testmig")]
|
||||
partial class testmig
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AssemblyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Assemblies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("AssemblyComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.ToTable("AssemblyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.Models.ComponentSupply", 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>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("ComponentSupplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("EquipmentReceivings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceivingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("AssemblyComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Assemblies")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null)
|
||||
.WithMany("Receivings")
|
||||
.HasForeignKey("SupplyId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("SupplyOrders")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("AssemblyComponents");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Assemblies");
|
||||
|
||||
b.Navigation("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Receivings");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,506 +0,0 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using ComputerShopDatabaseImplement;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerShopDatabase))]
|
||||
[Migration("20230407135446_clientmigration")]
|
||||
partial class clientmigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.4")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("AssemblyName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Price")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Assemblies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("AssemblyComponents");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("AssemblyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("AssemblyId");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.ToTable("AssemblyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.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("ComputerShopDatabaseImplement.Models.ComponentSupply", 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>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("ComponentSupplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int?>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("EquipmentReceivings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", 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<string>("ComponentName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<double>("Sum")
|
||||
.HasColumnType("float");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.HasIndex("ComponentId");
|
||||
|
||||
b.ToTable("Purchases");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DateCreate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<DateTime?>("DateImplement")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ReceivingId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ClientId");
|
||||
|
||||
b.ToTable("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("OrderId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("SupplyId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("OrderId");
|
||||
|
||||
b.HasIndex("SupplyId");
|
||||
|
||||
b.ToTable("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Assemblies")
|
||||
.HasForeignKey("ClientId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyComponent", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("AssemblyComponents")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.AssemblyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Assembly", "Assembly")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("AssemblyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("Assemblies")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Assembly");
|
||||
|
||||
b.Navigation("Order");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.EquipmentReceiving", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("EquipmentReceivings")
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", null)
|
||||
.WithMany("Receivings")
|
||||
.HasForeignKey("SupplyId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("ClientId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId");
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ComponentId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Supplies")
|
||||
.HasForeignKey("ClientId");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Order", "Order")
|
||||
.WithMany("SupplyOrders")
|
||||
.HasForeignKey("OrderId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Supply", "Supply")
|
||||
.WithMany("Orders")
|
||||
.HasForeignKey("SupplyId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Order");
|
||||
|
||||
b.Navigation("Supply");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Assembly", b =>
|
||||
{
|
||||
b.Navigation("Components");
|
||||
|
||||
b.Navigation("Orders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Client", b =>
|
||||
{
|
||||
b.Navigation("Assemblies");
|
||||
|
||||
b.Navigation("EquipmentReceivings");
|
||||
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Component", b =>
|
||||
{
|
||||
b.Navigation("AssemblyComponents");
|
||||
|
||||
b.Navigation("Purchases");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
|
||||
{
|
||||
b.Navigation("Assemblies");
|
||||
|
||||
b.Navigation("SupplyOrders");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
|
||||
{
|
||||
b.Navigation("Orders");
|
||||
|
||||
b.Navigation("Receivings");
|
||||
|
||||
b.Navigation("Supplies");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -1,186 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class clientmigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Supplies",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Purchases",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Orders",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "EquipmentReceivings",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Assemblies",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
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.CreateIndex(
|
||||
name: "IX_Supplies_ClientId",
|
||||
table: "Supplies",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ClientId",
|
||||
table: "Purchases",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EquipmentReceivings_ClientId",
|
||||
table: "EquipmentReceivings",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Assemblies_ClientId",
|
||||
table: "Assemblies",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Assemblies_Clients_ClientId",
|
||||
table: "Assemblies",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
||||
table: "EquipmentReceivings",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Purchases_Clients_ClientId",
|
||||
table: "Purchases",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Supplies_Clients_ClientId",
|
||||
table: "Supplies",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Assemblies_Clients_ClientId",
|
||||
table: "Assemblies");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
||||
table: "EquipmentReceivings");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Orders_Clients_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Purchases_Clients_ClientId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Supplies_Clients_ClientId",
|
||||
table: "Supplies");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Supplies_ClientId",
|
||||
table: "Supplies");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Purchases_ClientId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_EquipmentReceivings_ClientId",
|
||||
table: "EquipmentReceivings");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Assemblies_ClientId",
|
||||
table: "Assemblies");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Supplies");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Purchases");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Orders");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "EquipmentReceivings");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Assemblies");
|
||||
}
|
||||
}
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class clientmigration2 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<int>(
|
||||
name: "ClientId",
|
||||
table: "Components",
|
||||
type: "int",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Components_ClientId",
|
||||
table: "Components",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Components_Clients_ClientId",
|
||||
table: "Components",
|
||||
column: "ClientId",
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Components_Clients_ClientId",
|
||||
table: "Components");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Components_ClientId",
|
||||
table: "Components");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ClientId",
|
||||
table: "Components");
|
||||
}
|
||||
}
|
||||
}
|
@ -12,8 +12,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(ComputerShopDatabase))]
|
||||
[Migration("20230407145805_clientmigration2")]
|
||||
partial class clientmigration2
|
||||
[Migration("20230408091846_newmigration")]
|
||||
partial class newmigration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -135,7 +135,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
@ -245,7 +245,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
@ -387,7 +387,9 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ClientId");
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
@ -429,9 +431,11 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId");
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Purchases")
|
||||
@ -439,6 +443,8 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
@ -6,11 +6,26 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
||||
namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class testmig : Migration
|
||||
public partial class newmigration : 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: "Assemblies",
|
||||
columns: table => new
|
||||
@ -18,11 +33,17 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
AssemblyName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Price = table.Column<double>(type: "float", nullable: false)
|
||||
Price = table.Column<double>(type: "float", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Assemblies", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Assemblies_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -32,11 +53,18 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
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)
|
||||
Cost = table.Column<double>(type: "float", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Components", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Components_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -48,11 +76,17 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
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)
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
ClientId = table.Column<int>(type: "int", 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");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -65,11 +99,17 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
DateCreate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
OrderId = table.Column<int>(type: "int", nullable: false),
|
||||
ReceivingId = table.Column<int>(type: "int", nullable: false)
|
||||
ReceivingId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Supplies", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Supplies_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -107,6 +147,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
ComponentName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
ComponentId = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
Sum = table.Column<double>(type: "float", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
@ -116,12 +157,18 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Purchases", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
table.ForeignKey(
|
||||
name: "FK_Purchases_Components_ComponentId",
|
||||
column: x => x.ComponentId,
|
||||
principalTable: "Components",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
onDelete: ReferentialAction.NoAction);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -186,11 +233,17 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DateImplement = table.Column<DateTime>(type: "datetime2", nullable: true),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
ClientId = table.Column<int>(type: "int", nullable: true),
|
||||
SupplyId = table.Column<int>(type: "int", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EquipmentReceivings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_EquipmentReceivings_Clients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_EquipmentReceivings_Supplies_SupplyId",
|
||||
column: x => x.SupplyId,
|
||||
@ -225,6 +278,11 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Assemblies_ClientId",
|
||||
table: "Assemblies",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_AssemblyComponents_AssemblyId",
|
||||
table: "AssemblyComponents",
|
||||
@ -245,6 +303,11 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
table: "AssemblyOrders",
|
||||
column: "OrderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Components_ClientId",
|
||||
table: "Components",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ComponentSupplies_ComponentId",
|
||||
table: "ComponentSupplies",
|
||||
@ -255,16 +318,36 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
table: "ComponentSupplies",
|
||||
column: "SupplyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EquipmentReceivings_ClientId",
|
||||
table: "EquipmentReceivings",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EquipmentReceivings_SupplyId",
|
||||
table: "EquipmentReceivings",
|
||||
column: "SupplyId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Orders_ClientId",
|
||||
table: "Orders",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ClientId",
|
||||
table: "Purchases",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Purchases_ComponentId",
|
||||
table: "Purchases",
|
||||
column: "ComponentId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Supplies_ClientId",
|
||||
table: "Supplies",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_SupplyOrders_OrderId",
|
||||
table: "SupplyOrders",
|
||||
@ -308,6 +391,9 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Supplies");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
}
|
||||
}
|
||||
}
|
@ -132,7 +132,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("ComponentName")
|
||||
@ -242,7 +242,7 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int?>("ClientId")
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("ComponentId")
|
||||
@ -384,7 +384,9 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
.WithMany("Components")
|
||||
.HasForeignKey("ClientId");
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.ComponentSupply", b =>
|
||||
@ -426,9 +428,11 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
|
||||
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
|
||||
{
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
|
||||
.WithMany("Purchases")
|
||||
.HasForeignKey("ClientId");
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
|
||||
.WithMany("Purchases")
|
||||
@ -436,6 +440,8 @@ namespace ComputerShopDatabaseImplement.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Client");
|
||||
|
||||
b.Navigation("Component");
|
||||
});
|
||||
|
||||
|
@ -18,6 +18,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
public string ComponentName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public double Cost { get; set; }
|
||||
public int ClientId { get; private set; }
|
||||
[ForeignKey("ComponentId")]
|
||||
public virtual List<AssemblyComponent> AssemblyComponents { get; set; } =
|
||||
new();
|
||||
@ -35,7 +36,8 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
Cost = model.Cost,
|
||||
ClientId = model.ClientId
|
||||
};
|
||||
}
|
||||
public static Component Create(ComponentViewModel model)
|
||||
@ -44,7 +46,8 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
{
|
||||
Id = model.Id,
|
||||
ComponentName = model.ComponentName,
|
||||
Cost = model.Cost
|
||||
Cost = model.Cost,
|
||||
ClientId = model.ClientId
|
||||
};
|
||||
}
|
||||
public void Update(ComponentBindingModel model)
|
||||
@ -55,12 +58,14 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
}
|
||||
ComponentName = model.ComponentName;
|
||||
Cost = model.Cost;
|
||||
ClientId = model.ClientId;
|
||||
}
|
||||
public ComponentViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ComponentName = ComponentName,
|
||||
Cost = Cost
|
||||
Cost = Cost,
|
||||
ClientId = ClientId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
[Required]
|
||||
public int ComponentId { get; private set; }
|
||||
[Required]
|
||||
public int ClientId { get; private set; }
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
[Required]
|
||||
public double Sum { get; private set; }
|
||||
@ -29,6 +31,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
|
||||
public DateTime? DateImplement { get; private set; }
|
||||
public virtual Component Component { get; set; }
|
||||
public virtual Client Client { get; set; }
|
||||
|
||||
public static Purchase? Create(PurchaseBindingModel? model)
|
||||
{
|
||||
@ -46,6 +49,7 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
DateCreate = model.DateCreate,
|
||||
DateImplement = model.DateImplement,
|
||||
Id = model.Id,
|
||||
ClientId = model.ClientId
|
||||
};
|
||||
}
|
||||
|
||||
@ -59,16 +63,25 @@ namespace ComputerShopDatabaseImplement.Models
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
public PurchaseViewModel GetViewModel => new()
|
||||
public PurchaseViewModel GetViewModel
|
||||
{
|
||||
ComponentId = ComponentId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
ComponentName = ComponentName
|
||||
};
|
||||
get
|
||||
{
|
||||
var context = new ComputerShopDatabase();
|
||||
return new()
|
||||
{
|
||||
ComponentId = ComponentId,
|
||||
ClientId = ClientId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
DateCreate = DateCreate,
|
||||
DateImplement = DateImplement,
|
||||
Id = Id,
|
||||
Status = Status,
|
||||
ComponentName = context.Components.FirstOrDefault(x => x.Id == ComponentId)?.ComponentName ?? string.Empty,
|
||||
ClientFIO = context.Clients.FirstOrDefault(x => x.Id == ClientId)?.ClientFIO ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,47 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ComputerShopContracts.BindingModels;
|
||||
using ComputerShopContracts.BusinessLogicContracts;
|
||||
using ComputerShopContracts.SearchModels;
|
||||
using ComputerShopContracts.ViewModels;
|
||||
|
||||
namespace ComputerShopRestApi.Controllers
|
||||
{
|
||||
[Route("api/[controller]/[action]")]
|
||||
[ApiController]
|
||||
public class ComponentController : Controller
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IComponentLogic _component;
|
||||
public ComponentController(ILogger<MainController> logger, IComponentLogic component)
|
||||
{
|
||||
_logger = logger;
|
||||
_component = component;
|
||||
}
|
||||
[HttpGet]
|
||||
public List<ComponentViewModel>? GetComponentList()
|
||||
{
|
||||
try
|
||||
{
|
||||
return _component.ReadList(null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка компонентов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public void CreateComponent(ComponentBindingModel model)
|
||||
{
|
||||
try
|
||||
{
|
||||
_component.Create(model);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания компонента");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user