diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.Designer.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.Designer.cs new file mode 100644 index 0000000..c0687df --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.Designer.cs @@ -0,0 +1,465 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ServiceStationDatabaseImplement; + +#nullable disable + +namespace ServiceStationDatabaseImplement.Migrations +{ + [DbContext(typeof(ServiceStationDatabase))] + [Migration("20230520045521_init")] + partial class init + { + /// + 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("ServiceStationDatabaseImplement.Models.Car", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Model") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VIN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Cars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SpareId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.HasIndex("SpareId"); + + b.ToTable("CarSpares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Employers"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("EmployerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployerId"); + + b.ToTable("Maintenances"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MaintenanceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.HasIndex("MaintenanceId"); + + b.ToTable("MaintenanceCars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("ServiceDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Spare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Storekeepers"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DurationId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("DurationId"); + + b.HasIndex("StorekeeperId"); + + b.ToTable("Works"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkDuration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Duration") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("WorkDurations"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MaintenanceId") + .HasColumnType("int"); + + b.Property("MaintenceId") + .HasColumnType("int"); + + b.Property("WorkId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceId"); + + b.HasIndex("WorkId"); + + b.ToTable("WorkMaintences"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SpareId") + .HasColumnType("int"); + + b.Property("WorkId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SpareId"); + + b.HasIndex("WorkId"); + + b.ToTable("WorkSpares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car") + .WithMany("Spares") + .HasForeignKey("CarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Spare", "Spare") + .WithMany() + .HasForeignKey("SpareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Car"); + + b.Navigation("Spare"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Employer", null) + .WithMany("Maintenances") + .HasForeignKey("EmployerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car") + .WithMany() + .HasForeignKey("CarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Maintenance", "Maintenance") + .WithMany("Cars") + .HasForeignKey("MaintenanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Car"); + + b.Navigation("Maintenance"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", null) + .WithMany("Services") + .HasForeignKey("CarId"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.WorkDuration", null) + .WithMany("Works") + .HasForeignKey("DurationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Storekeeper", null) + .WithMany("Works") + .HasForeignKey("StorekeeperId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Maintenance", "Maintenance") + .WithMany() + .HasForeignKey("MaintenanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work") + .WithMany("Maintences") + .HasForeignKey("WorkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Maintenance"); + + b.Navigation("Work"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Spare", "Spare") + .WithMany() + .HasForeignKey("SpareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work") + .WithMany("Spares") + .HasForeignKey("WorkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Spare"); + + b.Navigation("Work"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b => + { + b.Navigation("Services"); + + b.Navigation("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b => + { + b.Navigation("Maintenances"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.Navigation("Cars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b => + { + b.Navigation("Works"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.Navigation("Maintences"); + + b.Navigation("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkDuration", b => + { + b.Navigation("Works"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.cs new file mode 100644 index 0000000..41354fe --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/20230520045521_init.cs @@ -0,0 +1,364 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace ServiceStationDatabaseImplement.Migrations +{ + /// + public partial class init : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Cars", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Brand = table.Column(type: "nvarchar(max)", nullable: false), + Model = table.Column(type: "nvarchar(max)", nullable: false), + VIN = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Cars", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Employers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Login = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Employers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Spares", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Name = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Spares", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Storekeepers", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Login = table.Column(type: "nvarchar(max)", nullable: false), + Password = table.Column(type: "nvarchar(max)", nullable: false), + Email = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Storekeepers", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "WorkDurations", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Duration = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkDurations", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Services", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceDescription = table.Column(type: "nvarchar(max)", nullable: false), + CarId = table.Column(type: "int", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Services", x => x.Id); + table.ForeignKey( + name: "FK_Services_Cars_CarId", + column: x => x.CarId, + principalTable: "Cars", + principalColumn: "Id"); + }); + + migrationBuilder.CreateTable( + name: "Maintenances", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + EmployerId = table.Column(type: "int", nullable: false), + Cost = table.Column(type: "float", nullable: false), + DateCreate = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Maintenances", x => x.Id); + table.ForeignKey( + name: "FK_Maintenances_Employers_EmployerId", + column: x => x.EmployerId, + principalTable: "Employers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "CarSpares", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + SpareId = table.Column(type: "int", nullable: false), + CarId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_CarSpares", x => x.Id); + table.ForeignKey( + name: "FK_CarSpares_Cars_CarId", + column: x => x.CarId, + principalTable: "Cars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_CarSpares_Spares_SpareId", + column: x => x.SpareId, + principalTable: "Spares", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Works", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + Title = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false), + StorekeeperId = table.Column(type: "int", nullable: false), + DurationId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Works", x => x.Id); + table.ForeignKey( + name: "FK_Works_Storekeepers_StorekeeperId", + column: x => x.StorekeeperId, + principalTable: "Storekeepers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_Works_WorkDurations_DurationId", + column: x => x.DurationId, + principalTable: "WorkDurations", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MaintenanceCars", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MaintenanceId = table.Column(type: "int", nullable: false), + CarId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MaintenanceCars", x => x.Id); + table.ForeignKey( + name: "FK_MaintenanceCars_Cars_CarId", + column: x => x.CarId, + principalTable: "Cars", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MaintenanceCars_Maintenances_MaintenanceId", + column: x => x.MaintenanceId, + principalTable: "Maintenances", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "WorkMaintences", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WorkId = table.Column(type: "int", nullable: false), + MaintenceId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false), + MaintenanceId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkMaintences", x => x.Id); + table.ForeignKey( + name: "FK_WorkMaintences_Maintenances_MaintenanceId", + column: x => x.MaintenanceId, + principalTable: "Maintenances", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_WorkMaintences_Works_WorkId", + column: x => x.WorkId, + principalTable: "Works", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "WorkSpares", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + WorkId = table.Column(type: "int", nullable: false), + SpareId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_WorkSpares", x => x.Id); + table.ForeignKey( + name: "FK_WorkSpares_Spares_SpareId", + column: x => x.SpareId, + principalTable: "Spares", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_WorkSpares_Works_WorkId", + column: x => x.WorkId, + principalTable: "Works", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_CarSpares_CarId", + table: "CarSpares", + column: "CarId"); + + migrationBuilder.CreateIndex( + name: "IX_CarSpares_SpareId", + table: "CarSpares", + column: "SpareId"); + + migrationBuilder.CreateIndex( + name: "IX_MaintenanceCars_CarId", + table: "MaintenanceCars", + column: "CarId"); + + migrationBuilder.CreateIndex( + name: "IX_MaintenanceCars_MaintenanceId", + table: "MaintenanceCars", + column: "MaintenanceId"); + + migrationBuilder.CreateIndex( + name: "IX_Maintenances_EmployerId", + table: "Maintenances", + column: "EmployerId"); + + migrationBuilder.CreateIndex( + name: "IX_Services_CarId", + table: "Services", + column: "CarId"); + + migrationBuilder.CreateIndex( + name: "IX_WorkMaintences_MaintenanceId", + table: "WorkMaintences", + column: "MaintenanceId"); + + migrationBuilder.CreateIndex( + name: "IX_WorkMaintences_WorkId", + table: "WorkMaintences", + column: "WorkId"); + + migrationBuilder.CreateIndex( + name: "IX_Works_DurationId", + table: "Works", + column: "DurationId"); + + migrationBuilder.CreateIndex( + name: "IX_Works_StorekeeperId", + table: "Works", + column: "StorekeeperId"); + + migrationBuilder.CreateIndex( + name: "IX_WorkSpares_SpareId", + table: "WorkSpares", + column: "SpareId"); + + migrationBuilder.CreateIndex( + name: "IX_WorkSpares_WorkId", + table: "WorkSpares", + column: "WorkId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "CarSpares"); + + migrationBuilder.DropTable( + name: "MaintenanceCars"); + + migrationBuilder.DropTable( + name: "Services"); + + migrationBuilder.DropTable( + name: "WorkMaintences"); + + migrationBuilder.DropTable( + name: "WorkSpares"); + + migrationBuilder.DropTable( + name: "Cars"); + + migrationBuilder.DropTable( + name: "Maintenances"); + + migrationBuilder.DropTable( + name: "Spares"); + + migrationBuilder.DropTable( + name: "Works"); + + migrationBuilder.DropTable( + name: "Employers"); + + migrationBuilder.DropTable( + name: "Storekeepers"); + + migrationBuilder.DropTable( + name: "WorkDurations"); + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/ServiceStationDatabaseModelSnapshot.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/ServiceStationDatabaseModelSnapshot.cs new file mode 100644 index 0000000..08c0fa5 --- /dev/null +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/Migrations/ServiceStationDatabaseModelSnapshot.cs @@ -0,0 +1,462 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ServiceStationDatabaseImplement; + +#nullable disable + +namespace ServiceStationDatabaseImplement.Migrations +{ + [DbContext(typeof(ServiceStationDatabase))] + partial class ServiceStationDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.5") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Brand") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Model") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("VIN") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Cars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SpareId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.HasIndex("SpareId"); + + b.ToTable("CarSpares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Employers"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Cost") + .HasColumnType("float"); + + b.Property("DateCreate") + .HasColumnType("datetime2"); + + b.Property("EmployerId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("EmployerId"); + + b.ToTable("Maintenances"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MaintenanceId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.HasIndex("MaintenanceId"); + + b.ToTable("MaintenanceCars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CarId") + .HasColumnType("int"); + + b.Property("ServiceDescription") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("CarId"); + + b.ToTable("Services"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Spare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Price") + .HasColumnType("float"); + + b.HasKey("Id"); + + b.ToTable("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Login") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.ToTable("Storekeepers"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DurationId") + .HasColumnType("int"); + + b.Property("Price") + .HasColumnType("float"); + + b.Property("StorekeeperId") + .HasColumnType("int"); + + b.Property("Title") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("DurationId"); + + b.HasIndex("StorekeeperId"); + + b.ToTable("Works"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkDuration", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Duration") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.ToTable("WorkDurations"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("MaintenanceId") + .HasColumnType("int"); + + b.Property("MaintenceId") + .HasColumnType("int"); + + b.Property("WorkId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("MaintenanceId"); + + b.HasIndex("WorkId"); + + b.ToTable("WorkMaintences"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("int"); + + b.Property("SpareId") + .HasColumnType("int"); + + b.Property("WorkId") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("SpareId"); + + b.HasIndex("WorkId"); + + b.ToTable("WorkSpares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car") + .WithMany("Spares") + .HasForeignKey("CarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Spare", "Spare") + .WithMany() + .HasForeignKey("SpareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Car"); + + b.Navigation("Spare"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Employer", null) + .WithMany("Maintenances") + .HasForeignKey("EmployerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", "Car") + .WithMany() + .HasForeignKey("CarId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Maintenance", "Maintenance") + .WithMany("Cars") + .HasForeignKey("MaintenanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Car"); + + b.Navigation("Maintenance"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Car", null) + .WithMany("Services") + .HasForeignKey("CarId"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.WorkDuration", null) + .WithMany("Works") + .HasForeignKey("DurationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Storekeeper", null) + .WithMany("Works") + .HasForeignKey("StorekeeperId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Maintenance", "Maintenance") + .WithMany() + .HasForeignKey("MaintenanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work") + .WithMany("Maintences") + .HasForeignKey("WorkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Maintenance"); + + b.Navigation("Work"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b => + { + b.HasOne("ServiceStationDatabaseImplement.Models.Spare", "Spare") + .WithMany() + .HasForeignKey("SpareId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("ServiceStationDatabaseImplement.Models.Work", "Work") + .WithMany("Spares") + .HasForeignKey("WorkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Spare"); + + b.Navigation("Work"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Car", b => + { + b.Navigation("Services"); + + b.Navigation("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b => + { + b.Navigation("Maintenances"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b => + { + b.Navigation("Cars"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b => + { + b.Navigation("Works"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b => + { + b.Navigation("Maintences"); + + b.Navigation("Spares"); + }); + + modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkDuration", b => + { + b.Navigation("Works"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs index f2df186..776ee85 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationDatabaseImplement/ServiceStationDatabase.cs @@ -9,7 +9,7 @@ namespace ServiceStationDatabaseImplement { if (!optionsBuilder.IsConfigured) { - optionsBuilder.UseSqlServer(@"Data Source=localhost\SQLEXPRESS05;Initial Catalog=ServiceStation;Integrated Security=True;TrustServerCertificate=True"); + optionsBuilder.UseSqlServer(@"Data Source=IS-424-2-04\SQLEXPRESS;Initial Catalog=ServiceStation;Integrated Security=True;TrustServerCertificate=True"); } base.OnConfiguring(optionsBuilder); } diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Controllers/HomeController.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Controllers/HomeController.cs index 628bd42..28ed858 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Controllers/HomeController.cs +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Controllers/HomeController.cs @@ -1,18 +1,30 @@ using Microsoft.AspNetCore.Mvc; using ServiceStationContracts.BindingModels; using ServiceStationContracts.ViewModels; +using ServiceStationContracts.BusinessLogicsContracts; using ServiceStationEmployer.Models; +using ServiceStationBusinessLogic; using System.Diagnostics; +using ServiceStationContracts.SearchModels; namespace ServiceStationEmployer.Controllers { public class HomeController : Controller { private readonly ILogger _logger; + private readonly IEmployerLogic _employer; + private readonly IMaintenanceLogic _maintenanceLogic; + private readonly ICarLogic _carLogic; + private readonly IServiceLogic _serviceLogic; - public HomeController(ILogger logger) + public HomeController(ILogger logger, IEmployerLogic employerLogic, ICarLogic carLogic, IServiceLogic serviceLogic, IMaintenanceLogic maintenanceLogic) { + _employer = employerLogic; _logger = logger; + _carLogic = carLogic; + _serviceLogic = serviceLogic; + _maintenanceLogic = maintenanceLogic; + } public IActionResult Index() @@ -21,7 +33,7 @@ namespace ServiceStationEmployer.Controllers { return Redirect("~/Home/Enter"); } - return View(APIEmployer.GetRequest>($"api/Read/getWorks")); + return View(_carLogic.ReadList(null)); } public IActionResult Privacy() @@ -52,7 +64,11 @@ namespace ServiceStationEmployer.Controllers { throw new Exception("Введите логин и пароль"); } - APIEmployer.Employer = APIEmployer.GetRequest($"api/Main/LoginEmployer?login={login}&password={password}"); + APIEmployer.Employer = _employer.ReadElement(new EmployerSearchModel() + { + Login = login, + Password = password + }); if (APIEmployer.Employer == null) { throw new Exception("Неверный логин/пароль"); @@ -67,17 +83,17 @@ namespace ServiceStationEmployer.Controllers } [HttpPost] - public void Register(string login, string password, string fio) + public void Register(string login, string password, string email) { - if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(fio)) + if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password) || string.IsNullOrEmpty(email)) { throw new Exception("Введите логин, пароль и ФИО"); } - APIEmployer.PostRequest("api/Main/RegisterEmployer", new StorekeeperBindingModel - { - Login = fio, - Email = login, - Password = password + _employer.Create(new EmployerBindingModel() { + Login = login, + Email = email, + Password=password, + }); Response.Redirect("Enter"); return; @@ -96,13 +112,11 @@ namespace ServiceStationEmployer.Controllers { throw new Exception("Вы как суда попали? Суда вход только авторизованным"); } - APIEmployer.PostRequest("api/Main/CreateWork", new WorkBindingModel - { - DurationId = 1, - Price = price, - Title = title, - StorekeeperId = APIEmployer.Employer.Id - }); ; + _carLogic.Create(new CarBindingModel() { + Brand = title, + Model = title, + VIN = price.ToString() + }); Response.Redirect("Index"); } } diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Program.cs b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Program.cs index b4e8a1f..1b2de32 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Program.cs +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Program.cs @@ -1,3 +1,7 @@ +using ServiceStationBusinessLogic.BusinessLogics; +using ServiceStationContracts.BusinessLogicsContracts; +using ServiceStationContracts.StoragesContracts; +using ServiceStationDatabaseImplement.Implements; using ServiceStationEmployer; var builder = WebApplication.CreateBuilder(args); @@ -5,6 +9,25 @@ var builder = WebApplication.CreateBuilder(args); // Add services to the container. builder.Services.AddControllersWithViews(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); +builder.Services.AddTransient(); + + var app = builder.Build(); APIEmployer.Connect(builder.Configuration); diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/ServiceStationEmployer.csproj b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/ServiceStationEmployer.csproj index ca634a0..21f27af 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/ServiceStationEmployer.csproj +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/ServiceStationEmployer.csproj @@ -1,4 +1,4 @@ - + net6.0 @@ -11,7 +11,9 @@ + + diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Create.cshtml b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Create.cshtml index e1dd794..fd869d7 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Create.cshtml +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Create.cshtml @@ -1,5 +1,22 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ -@{ +@{ + ViewData["Title"] = "Create"; } +
+

Создание ТО

+
+
+
+
Название:
+
+
+
+
Цена:
+
+
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Index.cshtml b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Index.cshtml index e1dd794..3c96dc7 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Index.cshtml +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Index.cshtml @@ -1,5 +1,63 @@ -@* - For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 -*@ +@using ServiceStationContracts.ViewModels + +@model List + @{ + ViewData["Title"] = "Home Page"; } + +
+

ТО

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

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

+ return; + } + +

+ Создать ТО +

+ + + + + + + + + + + @foreach (var item in Model) + { + + + + + + + } + +
+ Номер + + Стоимость + + Дата создания + + Работник +
+ @Html.DisplayFor(modelItem => item.Id) + + @Html.DisplayFor(modelItem => item.Brand) + + @Html.DisplayFor(modelItem => item.Model) + + @Html.DisplayFor(modelItem => item.VIN) +
+ } +
\ No newline at end of file diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Register.cshtml b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Register.cshtml index aef7d64..e2b7107 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Register.cshtml +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Home/Register.cshtml @@ -8,11 +8,11 @@
Логин:
-
+
Почта:
-
+
Пароль:
diff --git a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Shared/_Layout.cshtml b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Shared/_Layout.cshtml index dba6f27..8398479 100644 --- a/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Shared/_Layout.cshtml +++ b/Semikolenov_G.A.CourseWork_ServiceStation/ServiceStationEmployer/Views/Shared/_Layout.cshtml @@ -23,7 +23,7 @@