This commit is contained in:
devil_1nc 2023-05-20 09:23:37 +04:00
parent 4967f035d9
commit b4e92e4686
6 changed files with 721 additions and 39 deletions

View File

@ -0,0 +1,540 @@
// <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("20230520051723_fix")]
partial class fix
{
/// <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<int>("ClientId")
.HasColumnType("int");
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Cost")
.HasColumnType("float");
b.HasKey("Id");
b.HasIndex("ClientId");
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.HasKey("Id");
b.HasIndex("ClientId");
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.HasIndex("ReceivingId");
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", "Client")
.WithMany("Assemblies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
});
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.Component", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Components")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
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("ComponentSupplies")
.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")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", "Client")
.WithMany("Purchases")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.Component", "Component")
.WithMany("Purchases")
.HasForeignKey("ComponentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Component");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies")
.HasForeignKey("ReceivingId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Receiving");
});
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("Components");
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.EquipmentReceiving", b =>
{
b.Navigation("Supplies");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{
b.Navigation("Assemblies");
b.Navigation("SupplyOrders");
});
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Supply", b =>
{
b.Navigation("ComponentSupplies");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,141 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ComputerShopDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class fix : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EquipmentReceivings_Clients_ClientId",
table: "EquipmentReceivings");
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Clients_ClientId",
table: "Supplies");
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "Supplies",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "Orders",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "EquipmentReceivings",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_EquipmentReceivings_Clients_ClientId",
table: "EquipmentReceivings",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
migrationBuilder.AddForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
migrationBuilder.AddForeignKey(
name: "FK_Supplies_Clients_ClientId",
table: "Supplies",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.NoAction);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_EquipmentReceivings_Clients_ClientId",
table: "EquipmentReceivings");
migrationBuilder.DropForeignKey(
name: "FK_Orders_Clients_ClientId",
table: "Orders");
migrationBuilder.DropForeignKey(
name: "FK_Supplies_Clients_ClientId",
table: "Supplies");
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "Supplies",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "Orders",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AlterColumn<int>(
name: "ClientId",
table: "EquipmentReceivings",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
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_Supplies_Clients_ClientId",
table: "Supplies",
column: "ClientId",
principalTable: "Clients",
principalColumn: "Id");
}
}
}

View File

@ -183,7 +183,7 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
@ -207,7 +207,7 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
@ -279,7 +279,7 @@ namespace ComputerShopDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("ClientId") b.Property<int>("ClientId")
.HasColumnType("int"); .HasColumnType("int");
b.Property<DateTime>("DateCreate") b.Property<DateTime>("DateCreate")
@ -413,14 +413,18 @@ namespace ComputerShopDatabaseImplement.Migrations
{ {
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("EquipmentReceivings") .WithMany("EquipmentReceivings")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.Purchase", b =>
@ -446,13 +450,17 @@ namespace ComputerShopDatabaseImplement.Migrations
{ {
b.HasOne("ComputerShopDatabaseImplement.Models.Client", null) b.HasOne("ComputerShopDatabaseImplement.Models.Client", null)
.WithMany("Supplies") .WithMany("Supplies")
.HasForeignKey("ClientId"); .HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", null) b.HasOne("ComputerShopDatabaseImplement.Models.EquipmentReceiving", "Receiving")
.WithMany("Supplies") .WithMany("Supplies")
.HasForeignKey("ReceivingId") .HasForeignKey("ReceivingId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Receiving");
}); });
modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b => modelBuilder.Entity("ComputerShopDatabaseImplement.Models.SupplyOrder", b =>

View File

@ -44,7 +44,7 @@ namespace ComputerShopRestApi.Controllers
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения списка закупок клиента id ={ Id}", clientId); _logger.LogError(ex, "Ошибка получения списка получений клиента id ={ Id}", clientId);
throw; throw;
} }
} }

View File

@ -25,15 +25,19 @@ namespace ComputerShopRestApi.Controllers
} }
[HttpGet] [HttpGet]
public List<EquipmentReceivingViewModel>? GetReceivingList() public List<EquipmentReceivingViewModel>? GetReceivingList(int clientId)
{ {
try try
{ {
return _equipmentReceiving.ReadList(null); return _equipmentReceiving.ReadList(new EquipmentReceivingSearchModel
{
ClientId = clientId
});
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка получения списка компонентов"); _logger.LogError(ex, "Ошибка получения списка поставок клиента id ={ Id}", clientId);
throw; throw;
} }
} }
@ -66,7 +70,7 @@ namespace ComputerShopRestApi.Controllers
} }
} }
[HttpPost] [HttpPost]
public void CreateAssembly(SupplyBindingModel model) public void CreateSupply(SupplyBindingModel model)
{ {
try try
{ {

View File

@ -127,54 +127,43 @@ namespace OrdererClientApp.Controllers
} }
[HttpGet] [HttpGet]
public IActionResult CreatePurchase() public IActionResult CreateEquipmentReceiving()
{ {
ViewBag.Components = APIClient.GetRequest<List<ComponentViewModel>>("api/main/getcomponentlist"); ViewBag.EquipmentReceivings = APIClient.GetRequest<List<EquipmentReceivingViewModel>>("api/main/getreceivingslist");
return View(); return View();
} }
[HttpPost] [HttpPost]
public void CreatePurchase(int component, int count) public void CreateSupply(int receiving)
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (count <= 0)
{ APIClient.PostRequest("api/main/createreceiving", new SupplyBindingModel
throw new Exception("Количество и сумма должны быть больше 0");
}
APIClient.PostRequest("api/main/createpurchase", new PurchaseBindingModel
{ {
ClientId = APIClient.Client.Id, ClientId = APIClient.Client.Id,
ComponentId = component, ReceivingId = receiving,
Count = count,
Sum = Calc(count, component)
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet] [HttpGet]
public IActionResult CreateComponent() public IActionResult CreateOrder()
{ {
return View(); return View();
} }
[HttpPost] [HttpPost]
public void CreateComponent(string name, int cost) public void CreateOrder(int sum)
{ {
if (APIClient.Client == null) if (APIClient.Client == null)
{ {
throw new Exception("Вы как суда попали? Суда вход только авторизованным"); throw new Exception("Вы как суда попали? Суда вход только авторизованным");
} }
if (cost <= 0) APIClient.PostRequest("api/order/createorder", new OrderBindingModel
{
throw new Exception("Цена должна быть больше 0");
}
APIClient.PostRequest("api/component/createcomponent", new ComponentBindingModel
{ {
ClientId = APIClient.Client.Id, ClientId = APIClient.Client.Id,
ComponentName = name,
Cost = cost
}); });
Response.Redirect("Index"); Response.Redirect("Index");
} }
@ -218,13 +207,13 @@ namespace OrdererClientApp.Controllers
{ {
throw new Exception("Сумма должна быть больше 0"); throw new Exception("Сумма должна быть больше 0");
} }
//APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel APIClient.PostRequest("api/assembly/createassembly", new AssemblyBindingModel
//{ {
// ClientId = APIClient.Client.Id, ClientId = APIClient.Client.Id,
// AssemblyName = name, AssemblyName = name,
// Price = 0, Price = 0,
// AssemblyComponents = new() AssemblyComponents = new()
//}); });
System.Diagnostics.Debug.WriteLine("it might work"); System.Diagnostics.Debug.WriteLine("it might work");
Response.Redirect("Index"); Response.Redirect("Index");
} }