From 086dd8bc65a4060c9c7e761fd9d3540b574ac547 Mon Sep 17 00:00:00 2001 From: Yunusov_Niyaz Date: Sun, 7 Apr 2024 22:59:40 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9D=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CarRepairShop/CarRepairShop.sln | 16 +- .../CarRepairShop/FormMain.Designer.cs | 22 +- .../20240407151705_InitialCreate.Designer.cs | 214 ++++++++++++++++++ .../20240407151705_InitialCreate.cs | 155 +++++++++++++ .../RepairsShopDatabaseModelSnapshot.cs | 211 +++++++++++++++++ .../Models/Order.cs | 3 +- .../CarRepairShopRestApi.csproj | 12 +- .../Controllers/ClientController.cs | 1 - .../Controllers/MainController.cs | 15 +- CarRepairShop/CarRepairShopRestApi/Program.cs | 10 +- .../Properties/launchSettings.json | 6 +- .../CarRepairShopRestApi/log4net.config | 26 +-- .../CarRepairShowClientApp/APIClient.cs | 4 +- .../Controllers/HomeController.cs | 134 ++++++++++- .../CarRepairShowClientApp/Program.cs | 17 +- .../Views/Home/Create.cshtml | 57 +++++ .../Views/Home/Enter.cshtml | 20 ++ .../Views/Home/Index.cshtml | 77 ++++++- .../Views/Home/Privacy.cshtml | 34 ++- .../Views/Home/Register.cshtml | 28 +++ .../Views/Shared/_Layout.cshtml | 92 ++++---- .../CarRepairShowClientApp/appsettings.json | 19 +- 22 files changed, 1023 insertions(+), 150 deletions(-) create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.Designer.cs create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.cs create mode 100644 CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs create mode 100644 CarRepairShop/CarRepairShowClientApp/Views/Home/Create.cshtml create mode 100644 CarRepairShop/CarRepairShowClientApp/Views/Home/Enter.cshtml create mode 100644 CarRepairShop/CarRepairShowClientApp/Views/Home/Register.cshtml diff --git a/CarRepairShop/CarRepairShop.sln b/CarRepairShop/CarRepairShop.sln index 15e543e..d0bfaf7 100644 --- a/CarRepairShop/CarRepairShop.sln +++ b/CarRepairShop/CarRepairShop.sln @@ -17,14 +17,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopFileImplement" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopDatabaseImplement", "CarRepairShopDatabaseImplement\CarRepairShopDatabaseImplement.csproj", "{F1BAC88A-6D0D-4276-92C4-757F48D0D80F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarRepairShopRestApi", "CarRepairShopRestApi\CarRepairShopRestApi.csproj", "{747BCB1C-6E82-4E5B-A03E-B1E66CF9182E}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarRepairShowClientApp", "CarRepairShowClientApp\CarRepairShowClientApp.csproj", "{952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShowClientApp", "CarRepairShowClientApp\CarRepairShowClientApp.csproj", "{952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}" ProjectSection(ProjectDependencies) = postProject - {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E} = {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E} + {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C} = {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C} {FA47DABA-C657-4049-B02A-6AB850A6D29E} = {FA47DABA-C657-4049-B02A-6AB850A6D29E} EndProjectSection EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CarRepairShopRestApi", "CarRepairShopRestApi\CarRepairShopRestApi.csproj", "{B576EFBD-68F1-4474-9E4A-E26D0C6FC84C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -59,14 +59,14 @@ Global {F1BAC88A-6D0D-4276-92C4-757F48D0D80F}.Debug|Any CPU.Build.0 = Debug|Any CPU {F1BAC88A-6D0D-4276-92C4-757F48D0D80F}.Release|Any CPU.ActiveCfg = Release|Any CPU {F1BAC88A-6D0D-4276-92C4-757F48D0D80F}.Release|Any CPU.Build.0 = Release|Any CPU - {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {747BCB1C-6E82-4E5B-A03E-B1E66CF9182E}.Release|Any CPU.Build.0 = Release|Any CPU {952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}.Debug|Any CPU.Build.0 = Debug|Any CPU {952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}.Release|Any CPU.ActiveCfg = Release|Any CPU {952D7FD8-9A39-4D35-A5EE-F16C7E6D2DBE}.Release|Any CPU.Build.0 = Release|Any CPU + {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B576EFBD-68F1-4474-9E4A-E26D0C6FC84C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/CarRepairShop/CarRepairShop/FormMain.Designer.cs b/CarRepairShop/CarRepairShop/FormMain.Designer.cs index baca232..8f62572 100644 --- a/CarRepairShop/CarRepairShop/FormMain.Designer.cs +++ b/CarRepairShop/CarRepairShop/FormMain.Designer.cs @@ -53,7 +53,7 @@ menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчётыToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; - menuStrip.Size = new Size(1082, 28); + menuStrip.Size = new Size(1286, 28); menuStrip.TabIndex = 0; menuStrip.Text = "Меню справочников"; // @@ -67,21 +67,21 @@ // компонентыToolStripMenuItem // компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - компонентыToolStripMenuItem.Size = new Size(224, 26); + компонентыToolStripMenuItem.Size = new Size(182, 26); компонентыToolStripMenuItem.Text = "Компоненты"; компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // ремонтToolStripMenuItem // ремонтToolStripMenuItem.Name = "ремонтToolStripMenuItem"; - ремонтToolStripMenuItem.Size = new Size(224, 26); + ремонтToolStripMenuItem.Size = new Size(182, 26); ремонтToolStripMenuItem.Text = "Ремонт"; ремонтToolStripMenuItem.Click += RepairToolStripMenuItem_Click; // // клиентыToolStripMenuItem // клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - клиентыToolStripMenuItem.Size = new Size(224, 26); + клиентыToolStripMenuItem.Size = new Size(182, 26); клиентыToolStripMenuItem.Text = "Клиенты"; клиентыToolStripMenuItem.Click += ClientsToolStripMenuItem_Click; // @@ -122,12 +122,12 @@ dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(839, 368); + dataGridView.Size = new Size(1004, 368); dataGridView.TabIndex = 1; // // buttonCreateOrder // - buttonCreateOrder.Location = new Point(858, 63); + buttonCreateOrder.Location = new Point(1042, 65); buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(212, 29); buttonCreateOrder.TabIndex = 2; @@ -137,7 +137,7 @@ // // buttonTakeOrderInWork // - buttonTakeOrderInWork.Location = new Point(858, 131); + buttonTakeOrderInWork.Location = new Point(1042, 125); buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; buttonTakeOrderInWork.Size = new Size(212, 29); buttonTakeOrderInWork.TabIndex = 3; @@ -147,7 +147,7 @@ // // buttonOrderReady // - buttonOrderReady.Location = new Point(858, 197); + buttonOrderReady.Location = new Point(1042, 190); buttonOrderReady.Name = "buttonOrderReady"; buttonOrderReady.Size = new Size(212, 29); buttonOrderReady.TabIndex = 4; @@ -157,7 +157,7 @@ // // buttonIssuedOrder // - buttonIssuedOrder.Location = new Point(858, 263); + buttonIssuedOrder.Location = new Point(1042, 259); buttonIssuedOrder.Name = "buttonIssuedOrder"; buttonIssuedOrder.Size = new Size(212, 29); buttonIssuedOrder.TabIndex = 5; @@ -167,7 +167,7 @@ // // buttonRefresh // - buttonRefresh.Location = new Point(858, 331); + buttonRefresh.Location = new Point(1042, 324); buttonRefresh.Name = "buttonRefresh"; buttonRefresh.Size = new Size(212, 29); buttonRefresh.TabIndex = 6; @@ -179,7 +179,7 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1082, 403); + ClientSize = new Size(1286, 403); Controls.Add(buttonRefresh); Controls.Add(buttonIssuedOrder); Controls.Add(buttonOrderReady); diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.Designer.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.Designer.cs new file mode 100644 index 0000000..69b8078 --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.Designer.cs @@ -0,0 +1,214 @@ +// +using System; +using CarRepairShopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CarRepairShopDatabaseImplement.Migrations +{ + [DbContext(typeof(RepairsShopDatabase))] + [Migration("20240407151705_InitialCreate")] + partial class InitialCreate + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.16") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("RepairId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Repair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("RepairName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Repairs"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.RepairComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("RepairId"); + + b.ToTable("RepairComponents"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("Orders") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.RepairComponent", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Component", "Component") + .WithMany("RepairComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("Components") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => + { + b.Navigation("RepairComponents"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Repair", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.cs new file mode 100644 index 0000000..5812add --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/20240407151705_InitialCreate.cs @@ -0,0 +1,155 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace CarRepairShopDatabaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Clients", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ClientFIO = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Clients", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Components", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ComponentName = table.Column(type: "nvarchar(max)", nullable: false), + Cost = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Components", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Repairs", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RepairName = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Repairs", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Orders", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Count = table.Column(type: "int", nullable: false), + Sum = table.Column(type: "float", nullable: false), + Status = table.Column(type: "int", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false), + DateImplement = table.Column(type: "datetime2", nullable: true), + RepairId = table.Column(type: "int", nullable: false), + ClientId = table.Column(type: "int", nullable: false) + }, + 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_Repairs_RepairId", + column: x => x.RepairId, + principalTable: "Repairs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "RepairComponents", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + RepairId = table.Column(type: "int", nullable: false), + ComponentId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_RepairComponents", x => x.Id); + table.ForeignKey( + name: "FK_RepairComponents_Components_ComponentId", + column: x => x.ComponentId, + principalTable: "Components", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_RepairComponents_Repairs_RepairId", + column: x => x.RepairId, + principalTable: "Repairs", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_Orders_RepairId", + table: "Orders", + column: "RepairId"); + + migrationBuilder.CreateIndex( + name: "IX_RepairComponents_ComponentId", + table: "RepairComponents", + column: "ComponentId"); + + migrationBuilder.CreateIndex( + name: "IX_RepairComponents_RepairId", + table: "RepairComponents", + column: "RepairId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Orders"); + + migrationBuilder.DropTable( + name: "RepairComponents"); + + migrationBuilder.DropTable( + name: "Clients"); + + migrationBuilder.DropTable( + name: "Components"); + + migrationBuilder.DropTable( + name: "Repairs"); + } + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs new file mode 100644 index 0000000..00f9df8 --- /dev/null +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Migrations/RepairsShopDatabaseModelSnapshot.cs @@ -0,0 +1,211 @@ +// +using System; +using CarRepairShopDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace CarRepairShopDatabaseImplement.Migrations +{ + [DbContext(typeof(RepairsShopDatabase))] + partial class RepairsShopDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.16") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Client", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Clients"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Cost") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Components"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ClientId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("DateImplement") + .HasColumnType("datetime2"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("RepairId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Repair", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("RepairName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Repairs"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.RepairComponent", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ComponentId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("RepairId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("ComponentId"); + + b.HasIndex("RepairId"); + + b.ToTable("RepairComponents"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Order", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("Orders") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.RepairComponent", b => + { + b.HasOne("CarRepairShopDatabaseImplement.Models.Component", "Component") + .WithMany("RepairComponents") + .HasForeignKey("ComponentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("CarRepairShopDatabaseImplement.Models.Repair", "Repair") + .WithMany("Components") + .HasForeignKey("RepairId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Component"); + + b.Navigation("Repair"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Component", b => + { + b.Navigation("RepairComponents"); + }); + + modelBuilder.Entity("CarRepairShopDatabaseImplement.Models.Repair", b => + { + b.Navigation("Components"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs index 9ba1064..52ba641 100644 --- a/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs +++ b/CarRepairShop/CarRepairShopDatabaseImplement/Models/Order.cs @@ -19,11 +19,10 @@ namespace CarRepairShopDatabaseImplement.Models public DateTime? DateImplement { get; private set; } [Required] public int RepairId { get; private set; } - public virtual Repair? Repairs { get; private set; } + public virtual Repair? Repair { get; private set; } [Required] public int ClientId { get; private set; } public virtual Client? Client { get; private set; } - public virtual Repair? Repair { get; set; } public static Order? Create(OrderBindingModel model) { diff --git a/CarRepairShop/CarRepairShopRestApi/CarRepairShopRestApi.csproj b/CarRepairShop/CarRepairShopRestApi/CarRepairShopRestApi.csproj index 6538553..398dae1 100644 --- a/CarRepairShop/CarRepairShopRestApi/CarRepairShopRestApi.csproj +++ b/CarRepairShop/CarRepairShopRestApi/CarRepairShopRestApi.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -6,16 +6,6 @@ enable - - - - - - - Always - - - diff --git a/CarRepairShop/CarRepairShopRestApi/Controllers/ClientController.cs b/CarRepairShop/CarRepairShopRestApi/Controllers/ClientController.cs index 8dca53a..08ae606 100644 --- a/CarRepairShop/CarRepairShopRestApi/Controllers/ClientController.cs +++ b/CarRepairShop/CarRepairShopRestApi/Controllers/ClientController.cs @@ -63,4 +63,3 @@ namespace CarRepairShopRestApi.Controllers } } } - diff --git a/CarRepairShop/CarRepairShopRestApi/Controllers/MainController.cs b/CarRepairShop/CarRepairShopRestApi/Controllers/MainController.cs index 3518219..10b330d 100644 --- a/CarRepairShop/CarRepairShopRestApi/Controllers/MainController.cs +++ b/CarRepairShop/CarRepairShopRestApi/Controllers/MainController.cs @@ -2,8 +2,6 @@ using CarRepairShopContracts.BusinessLogicsContracts; using CarRepairShopContracts.SearchModels; using CarRepairShopContracts.ViewModels; -using DocumentFormat.OpenXml.Office2010.Excel; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; namespace CarRepairShopRestApi.Controllers @@ -23,7 +21,7 @@ namespace CarRepairShopRestApi.Controllers _repair = repair; } [HttpGet] - public List? GetProductList() + public List? GetRepairList() { try { @@ -36,20 +34,18 @@ namespace CarRepairShopRestApi.Controllers } } [HttpGet] - public RepairViewModel? GetProduct(int productId) + public RepairViewModel? GetRepair(int repairId) { try { return _repair.ReadElement(new RepairSearchModel { - Id = - productId + Id = repairId }); } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения продукта по id={Id}", - productId); + _logger.LogError(ex, "Ошибка получения продукта по id={Id}", repairId); throw; } } @@ -65,7 +61,7 @@ namespace CarRepairShopRestApi.Controllers } catch (Exception ex) { - _logger.LogError(ex, "Ошибка получения списка заказов клиента id ={ Id}", clientId); + _logger.LogError(ex, "Ошибка получения списка заказов клиента id ={ Id} ", clientId); throw; } } @@ -83,4 +79,5 @@ namespace CarRepairShopRestApi.Controllers } } } + } diff --git a/CarRepairShop/CarRepairShopRestApi/Program.cs b/CarRepairShop/CarRepairShopRestApi/Program.cs index 1724c5e..f86ef1e 100644 --- a/CarRepairShop/CarRepairShopRestApi/Program.cs +++ b/CarRepairShop/CarRepairShopRestApi/Program.cs @@ -2,13 +2,13 @@ using CarRepairShopBusinessLogic.BusinessLogics; using CarRepairShopContracts.BusinessLogicsContracts; using CarRepairShopContracts.StoragesContracts; using CarRepairShopDatabaseImplement.Implements; - using Microsoft.OpenApi.Models; + var builder = WebApplication.CreateBuilder(args); builder.Logging.SetMinimumLevel(LogLevel.Trace); builder.Logging.AddLog4Net("log4net.config"); // Add services to the container. -builder.Services.AddTransient(); +builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -22,7 +22,7 @@ builder.Services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { - Title = "IceCreamShopRestApi", + Title = "CarRepairShopRestApi", Version = "v1" }); @@ -33,9 +33,9 @@ if (app.Environment.IsDevelopment()) { app.UseSwagger(); app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", - "IceCreamShopRestApi v1")); + "CarRepairShopRestApi v1")); } app.UseHttpsRedirection(); app.UseAuthorization(); app.MapControllers(); -app.Run(); \ No newline at end of file +app.Run(); diff --git a/CarRepairShop/CarRepairShopRestApi/Properties/launchSettings.json b/CarRepairShop/CarRepairShopRestApi/Properties/launchSettings.json index dfd367b..25ecbcd 100644 --- a/CarRepairShop/CarRepairShopRestApi/Properties/launchSettings.json +++ b/CarRepairShop/CarRepairShopRestApi/Properties/launchSettings.json @@ -4,8 +4,8 @@ "windowsAuthentication": false, "anonymousAuthentication": true, "iisExpress": { - "applicationUrl": "http://localhost:35194", - "sslPort": 44389 + "applicationUrl": "http://localhost:39213", + "sslPort": 44361 } }, "profiles": { @@ -14,7 +14,7 @@ "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", - "applicationUrl": "https://localhost:7136;http://localhost:5119", + "applicationUrl": "https://localhost:7189;http://localhost:5174", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/CarRepairShop/CarRepairShopRestApi/log4net.config b/CarRepairShop/CarRepairShopRestApi/log4net.config index b44adf5..697cef6 100644 --- a/CarRepairShop/CarRepairShopRestApi/log4net.config +++ b/CarRepairShop/CarRepairShopRestApi/log4net.config @@ -1,16 +1,16 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + \ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/APIClient.cs b/CarRepairShop/CarRepairShowClientApp/APIClient.cs index 334f038..c519a3e 100644 --- a/CarRepairShop/CarRepairShowClientApp/APIClient.cs +++ b/CarRepairShop/CarRepairShowClientApp/APIClient.cs @@ -32,8 +32,7 @@ namespace CarRepairShowClientApp public static void PostRequest(string requestUrl, T model) { var json = JsonConvert.SerializeObject(model); - var data = new StringContent(json, Encoding.UTF8, - "application/json"); + var data = new StringContent(json, Encoding.UTF8, "application/json"); var response = _client.PostAsync(requestUrl, data); var result = response.Result.Content.ReadAsStringAsync().Result; if (!response.Result.IsSuccessStatusCode) @@ -42,5 +41,4 @@ namespace CarRepairShowClientApp } } } - } diff --git a/CarRepairShop/CarRepairShowClientApp/Controllers/HomeController.cs b/CarRepairShop/CarRepairShowClientApp/Controllers/HomeController.cs index b4c5b34..ffb71c8 100644 --- a/CarRepairShop/CarRepairShowClientApp/Controllers/HomeController.cs +++ b/CarRepairShop/CarRepairShowClientApp/Controllers/HomeController.cs @@ -1,4 +1,6 @@ -using CarRepairShowClientApp.Models; +using CarRepairShopContracts.BindingModels; +using CarRepairShopContracts.ViewModels; +using CarRepairShowClientApp.Models; using Microsoft.AspNetCore.Mvc; using System.Diagnostics; @@ -7,26 +9,140 @@ namespace CarRepairShowClientApp.Controllers public class HomeController : Controller { private readonly ILogger _logger; - public HomeController(ILogger logger) { _logger = logger; } - public IActionResult Index() { - return View(); + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return + View(APIClient.GetRequest>($"api/main/getorders?clientId={APIClient.Client.Id}")); } - + [HttpGet] public IActionResult Privacy() { - return View(); + if (APIClient.Client == null) + { + return Redirect("~/Home/Enter"); + } + return View(APIClient.Client); } - - [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] + [HttpPost] + public void Privacy(string login, string password, string fio) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/client/updatedata", new + ClientBindingModel + { + Id = APIClient.Client.Id, + ClientFIO = fio, + Email = login, + Password = password + }); + APIClient.Client.ClientFIO = fio; + APIClient.Client.Email = login; + APIClient.Client.Password = password; + Response.Redirect("Index"); + } + [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, + NoStore = true)] public IActionResult Error() { - return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier }); + return View(new ErrorViewModel + { + RequestId = + Activity.Current?.Id ?? HttpContext.TraceIdentifier + }); + } + [HttpGet] + public IActionResult Enter() + { + return View(); + } + [HttpPost] + public void Enter(string login, string password) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password)) + { + throw new Exception("Введите логин и пароль"); + } + APIClient.Client = APIClient.GetRequest($"api/client/login?login={login}&password={password}"); + if (APIClient.Client == null) + { + throw new Exception("Неверный логин/пароль"); + } + Response.Redirect("Index"); + } + [HttpGet] + public IActionResult Register() + { + return View(); + } + [HttpPost] + public void Register(string login, string password, string fio) + { + if (string.IsNullOrEmpty(login) || + string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + { + throw new Exception("Введите логин, пароль и ФИО"); + } + APIClient.PostRequest("api/client/register", new + ClientBindingModel + { + ClientFIO = fio, + Email = login, + Password = password + }); + Response.Redirect("Enter"); + return; + } + [HttpGet] + public IActionResult Create() + { + ViewBag.Products = + APIClient.GetRequest>("api/main/getproductlist"); + return View(); + } + [HttpPost] + public void Create(int repair, int count) + { + if (APIClient.Client == null) + { + throw new Exception("Вы как суда попали? Суда вход только авторизованным"); + } + if (count <= 0) + { + throw new Exception("Количество и сумма должны быть больше 0"); + } + APIClient.PostRequest("api/main/createorder", new + OrderBindingModel + { + ClientId = APIClient.Client.Id, + RepairId = repair, + Count = count, + Sum = Calc(count, repair) + }); + Response.Redirect("Index"); + } + [HttpPost] + public double Calc(int count, int repair) + { + var rep = APIClient.GetRequest($"api/main/getproduct?productId={repair}" + ); + return count * (rep?.Price ?? 1); } } } \ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Program.cs b/CarRepairShop/CarRepairShowClientApp/Program.cs index 0727468..493e38b 100644 --- a/CarRepairShop/CarRepairShowClientApp/Program.cs +++ b/CarRepairShop/CarRepairShowClientApp/Program.cs @@ -1,10 +1,10 @@ -var builder = WebApplication.CreateBuilder(args); +using CarRepairShowClientApp; +var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); - var app = builder.Build(); - +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { @@ -12,16 +12,11 @@ if (!app.Environment.IsDevelopment()) // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } - app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseRouting(); - app.UseAuthorization(); - app.MapControllerRoute( - name: "default", - pattern: "{controller=Home}/{action=Index}/{id?}"); - -app.Run(); + name: "default", + pattern: "{controller=Home}/{action=Index}/{id?}"); +app.Run(); \ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Home/Create.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Home/Create.cshtml new file mode 100644 index 0000000..cd29b82 --- /dev/null +++ b/CarRepairShop/CarRepairShowClientApp/Views/Home/Create.cshtml @@ -0,0 +1,57 @@ +@{ + ViewData["Title"] = "Create"; +} + +
+

Создание заказа

+
+
+
+
Ремонт:
+
+ +
+
+
+
Количество:
+
+ +
+
+
+
Сумма:
+
+ +
+
+
+
+
+ +
+
+
+ \ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Home/Enter.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Home/Enter.cshtml new file mode 100644 index 0000000..4d663d4 --- /dev/null +++ b/CarRepairShop/CarRepairShowClientApp/Views/Home/Enter.cshtml @@ -0,0 +1,20 @@ +@{ + ViewData["Title"] = "Enter"; +} +
+

Вход в приложение

+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Home/Index.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Home/Index.cshtml index d2d19bd..a3cb021 100644 --- a/CarRepairShop/CarRepairShowClientApp/Views/Home/Index.cshtml +++ b/CarRepairShop/CarRepairShowClientApp/Views/Home/Index.cshtml @@ -1,8 +1,75 @@ -@{ - ViewData["Title"] = "Home Page"; +@using CarRepairShopContracts.ViewModels +@model List +@{ + ViewData["Title"] = "Home Page"; } -
-

Welcome

-

Learn about building Web apps with ASP.NET Core.

+

Заказы

+
+ @{ + if (Model == null) + { +

Авторизируйтесь

+ return; + } +

+ Создать заказ +

+ + + + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + + + } + +
+ Номер + + Ремонт + + Дата создания + + Количество + + Сумма + + Статус +
+ @Html.DisplayFor(modelItem => + item.Id) + + @Html.DisplayFor(modelItem => + item.RepairName) + + @Html.DisplayFor(modelItem => + item.DateCreate) + + @Html.DisplayFor(modelItem => + item.Count) + + @Html.DisplayFor(modelItem => + item.Sum) + + @Html.DisplayFor(modelItem => + item.Status) +
+ } +
\ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Home/Privacy.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Home/Privacy.cshtml index af4fb19..048c817 100644 --- a/CarRepairShop/CarRepairShowClientApp/Views/Home/Privacy.cshtml +++ b/CarRepairShop/CarRepairShowClientApp/Views/Home/Privacy.cshtml @@ -1,6 +1,30 @@ -@{ - ViewData["Title"] = "Privacy Policy"; +@using CarRepairShopContracts.ViewModels +@model ClientViewModel +@{ +ViewData["Title"] = "Privacy Policy"; } -

@ViewData["Title"]

- -

Use this page to detail your site's privacy policy.

+
+

Личные данные

+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
ФИО:
+
+
+
+
+
+
+
\ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Home/Register.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Home/Register.cshtml new file mode 100644 index 0000000..f27c970 --- /dev/null +++ b/CarRepairShop/CarRepairShowClientApp/Views/Home/Register.cshtml @@ -0,0 +1,28 @@ +@{ + ViewData["Title"] = "Register"; +} + +
+

Регистрация

+
+
+
+
Логин:
+
+
+
+
Пароль:
+
+
+
+
ФИО:
+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/Views/Shared/_Layout.cshtml b/CarRepairShop/CarRepairShowClientApp/Views/Shared/_Layout.cshtml index 1b8bb23..4f7f945 100644 --- a/CarRepairShop/CarRepairShowClientApp/Views/Shared/_Layout.cshtml +++ b/CarRepairShop/CarRepairShowClientApp/Views/Shared/_Layout.cshtml @@ -1,49 +1,53 @@ - + - - - @ViewData["Title"] - CarRepairShowClientApp - - - + + + @ViewData["Title"] - RepairShopClientApp + + + + -
- -
-
-
- @RenderBody() -
-
- -
-
- © 2024 - CarRepairShowClientApp - Privacy -
-
- - - - @await RenderSectionAsync("Scripts", required: false) +
+ +
+
+
+ @RenderBody() +
+
+ + + @RenderSection("Scripts", required: false) - + \ No newline at end of file diff --git a/CarRepairShop/CarRepairShowClientApp/appsettings.json b/CarRepairShop/CarRepairShowClientApp/appsettings.json index 8c7384d..5ef024d 100644 --- a/CarRepairShop/CarRepairShowClientApp/appsettings.json +++ b/CarRepairShop/CarRepairShowClientApp/appsettings.json @@ -1,12 +1,11 @@ { - { - "Logging": { - "LogLevel": { - "Default": "Information", - "Microsoft.AspNetCore": "Warning" - } - }, - "AllowedHosts": "*", - "IPAddress": "http://localhost:5159/" - } + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "ipaddress": "http://localhost:5174/" +}