diff --git a/Secure/SecureShopClientApp/Controllers/HomeController.cs b/Secure/SecureShopClientApp/Controllers/HomeController.cs index a3bc183..a75ccd0 100644 --- a/Secure/SecureShopClientApp/Controllers/HomeController.cs +++ b/Secure/SecureShopClientApp/Controllers/HomeController.cs @@ -39,8 +39,8 @@ namespace SecureShopClientApp.Controllers { if (APIClient.Client == null) { - throw new Exception("Вы как суда попали? Суда вход только авторизованным"); - } + throw new Exception("Вы как суда попали?"); + } if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) { throw new Exception("Введите логин, пароль и ФИО"); diff --git a/Secure/SecureShopClientApp/Program.cs b/Secure/SecureShopClientApp/Program.cs index 0727468..43433ee 100644 --- a/Secure/SecureShopClientApp/Program.cs +++ b/Secure/SecureShopClientApp/Program.cs @@ -1,3 +1,4 @@ +using SecureShopClientApp; var builder = WebApplication.CreateBuilder(args); // Add services to the container. @@ -5,6 +6,7 @@ builder.Services.AddControllersWithViews(); var app = builder.Build(); +APIClient.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.Designer.cs b/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.Designer.cs new file mode 100644 index 0000000..b8b8cf8 --- /dev/null +++ b/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.Designer.cs @@ -0,0 +1,214 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using SecureShopDatabaseImplement; + +#nullable disable + +namespace SecureShopDatabaseImplement.Migrations +{ + [DbContext(typeof(SecureShopDatabase))] + [Migration("20230504094937_Client add")] + partial class Clientadd + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("SecureShopDatabaseImplement.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("SecureShopDatabaseImplement.Models.Facilities", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("FacilitiesName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Facilitiess"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.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("SecureId") + .HasColumnType("int"); + + b.Property("Status") + .HasColumnType("int"); + + b.Property("Sum") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.HasIndex("ClientId"); + + b.HasIndex("SecureId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.Secure", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("SecureName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Secures"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.SecureFacilities", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("FacilitiesId") + .HasColumnType("int"); + + b.Property("SecureId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("FacilitiesId"); + + b.HasIndex("SecureId"); + + b.ToTable("SecureFacilitiess"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.Order", b => + { + b.HasOne("SecureShopDatabaseImplement.Models.Client", "Client") + .WithMany("Orders") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SecureShopDatabaseImplement.Models.Secure", "Secure") + .WithMany("Orders") + .HasForeignKey("SecureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Client"); + + b.Navigation("Secure"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.SecureFacilities", b => + { + b.HasOne("SecureShopDatabaseImplement.Models.Facilities", "Facilities") + .WithMany("SecureFacilitiess") + .HasForeignKey("FacilitiesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SecureShopDatabaseImplement.Models.Secure", "Secure") + .WithMany("Facilitiess") + .HasForeignKey("SecureId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Facilities"); + + b.Navigation("Secure"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.Client", b => + { + b.Navigation("Orders"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.Facilities", b => + { + b.Navigation("SecureFacilitiess"); + }); + + modelBuilder.Entity("SecureShopDatabaseImplement.Models.Secure", b => + { + b.Navigation("Facilitiess"); + + b.Navigation("Orders"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.cs b/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.cs new file mode 100644 index 0000000..3842e0b --- /dev/null +++ b/Secure/SecureShopDatabaseImplement/Migrations/20230504094937_Client add.cs @@ -0,0 +1,69 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace SecureShopDatabaseImplement.Migrations +{ + /// + public partial class Clientadd : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.Sql("DELETE FROM [dbo].[Orders]"); + migrationBuilder.AddColumn( + name: "ClientId", + table: "Orders", + type: "int", + nullable: false, + defaultValue: 0); + + 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.CreateIndex( + name: "IX_Orders_ClientId", + table: "Orders", + column: "ClientId"); + + migrationBuilder.AddForeignKey( + name: "FK_Orders_Clients_ClientId", + table: "Orders", + column: "ClientId", + principalTable: "Clients", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Orders_Clients_ClientId", + table: "Orders"); + + migrationBuilder.DropTable( + name: "Clients"); + + migrationBuilder.DropIndex( + name: "IX_Orders_ClientId", + table: "Orders"); + + migrationBuilder.DropColumn( + name: "ClientId", + table: "Orders"); + } + } +}