This commit is contained in:
user 2023-05-20 10:09:57 +04:00
parent 21abdf48be
commit 7708c53a2d
11 changed files with 1434 additions and 29 deletions

View File

@ -0,0 +1,465 @@
// <auto-generated />
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
{
/// <inheritdoc />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("VIN")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Cars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SpareId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("SpareId");
b.ToTable("CarSpares");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Employers");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<int>("EmployerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EmployerId");
b.ToTable("Maintenances");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MaintenanceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("MaintenanceId");
b.ToTable("MaintenanceCars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("CarId")
.HasColumnType("int");
b.Property<string>("ServiceDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("CarId");
b.ToTable("Services");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Spare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Spares");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DurationId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("StorekeeperId")
.HasColumnType("int");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Duration")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("WorkDurations");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MaintenanceId")
.HasColumnType("int");
b.Property<int>("MaintenceId")
.HasColumnType("int");
b.Property<int>("WorkId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MaintenanceId");
b.HasIndex("WorkId");
b.ToTable("WorkMaintences");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SpareId")
.HasColumnType("int");
b.Property<int>("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
}
}
}

View File

@ -0,0 +1,364 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace ServiceStationDatabaseImplement.Migrations
{
/// <inheritdoc />
public partial class init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Cars",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Brand = table.Column<string>(type: "nvarchar(max)", nullable: false),
Model = table.Column<string>(type: "nvarchar(max)", nullable: false),
VIN = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Cars", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Employers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Employers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Spares",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Spares", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Storekeepers",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Login = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Storekeepers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "WorkDurations",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Duration = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_WorkDurations", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Services",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ServiceDescription = table.Column<string>(type: "nvarchar(max)", nullable: false),
CarId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployerId = table.Column<int>(type: "int", nullable: false),
Cost = table.Column<double>(type: "float", nullable: false),
DateCreate = table.Column<DateTime>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
SpareId = table.Column<int>(type: "int", nullable: false),
CarId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Title = table.Column<string>(type: "nvarchar(max)", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
StorekeeperId = table.Column<int>(type: "int", nullable: false),
DurationId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
MaintenanceId = table.Column<int>(type: "int", nullable: false),
CarId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkId = table.Column<int>(type: "int", nullable: false),
MaintenceId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false),
MaintenanceId = table.Column<int>(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<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkId = table.Column<int>(type: "int", nullable: false),
SpareId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(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");
}
/// <inheritdoc />
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");
}
}
}

View File

@ -0,0 +1,462 @@
// <auto-generated />
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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Brand")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Model")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("VIN")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Cars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.CarSpare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SpareId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("SpareId");
b.ToTable("CarSpares");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Employer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Employers");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Maintenance", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<double>("Cost")
.HasColumnType("float");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<int>("EmployerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EmployerId");
b.ToTable("Maintenances");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.MaintenanceCar", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("CarId")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MaintenanceId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CarId");
b.HasIndex("MaintenanceId");
b.ToTable("MaintenanceCars");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Service", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int?>("CarId")
.HasColumnType("int");
b.Property<string>("ServiceDescription")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("CarId");
b.ToTable("Services");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Spare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("Id");
b.ToTable("Spares");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Storekeeper", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Login")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Storekeepers");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.Work", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("DurationId")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<int>("StorekeeperId")
.HasColumnType("int");
b.Property<string>("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<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Duration")
.HasColumnType("int");
b.HasKey("Id");
b.ToTable("WorkDurations");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkMaintence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("MaintenanceId")
.HasColumnType("int");
b.Property<int>("MaintenceId")
.HasColumnType("int");
b.Property<int>("WorkId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("MaintenanceId");
b.HasIndex("WorkId");
b.ToTable("WorkMaintences");
});
modelBuilder.Entity("ServiceStationDatabaseImplement.Models.WorkSpare", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SpareId")
.HasColumnType("int");
b.Property<int>("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
}
}
}

View File

@ -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);
}

View File

@ -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<HomeController> _logger;
private readonly IEmployerLogic _employer;
private readonly IMaintenanceLogic _maintenanceLogic;
private readonly ICarLogic _carLogic;
private readonly IServiceLogic _serviceLogic;
public HomeController(ILogger<HomeController> logger)
public HomeController(ILogger<HomeController> 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<List<WorkViewModel>>($"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<EmployerViewModel>($"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");
}
}

View File

@ -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<ICarStorage, CarStorage>();
builder.Services.AddTransient<IEmployerStorage, EmployerStorage>();
builder.Services.AddTransient<IMaintenanceStorage, MaintenanceStorage>();
builder.Services.AddTransient<IServiceStorage, ServiceStorage>();
builder.Services.AddTransient<ISpareStorage, SpareStorage>();
builder.Services.AddTransient<IStorekeeperStorage, StorekeeperStorage>();
builder.Services.AddTransient<IWorkDurationStorage, WorkDurationStorage>();
builder.Services.AddTransient<IWorkStorage, WorkStorage>();
builder.Services.AddTransient<ICarLogic, CarLogic>();
builder.Services.AddTransient<IEmployerLogic, EmployerLogic>();
builder.Services.AddTransient<IMaintenanceLogic, MaintenanceLogic>();
builder.Services.AddTransient<IServiceLogic, ServiceLogic>();
builder.Services.AddTransient<ISpareLogic, SpareLogic>();
builder.Services.AddTransient<IStorekeeperLogic, StorekeeperLogic>();
builder.Services.AddTransient<IWorkDurationLogic, WorkDurationLogic>();
builder.Services.AddTransient<IWorkLogic, WorkLogic>();
var app = builder.Build();
APIEmployer.Connect(builder.Configuration);

View File

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@ -11,7 +11,9 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ServiceStationBusinessLogic\ServiceStationBusinessLogic.csproj" />
<ProjectReference Include="..\ServiceStationContracts\ServiceStationContracts.csproj" />
<ProjectReference Include="..\ServiceStationDatabaseImplement\ServiceStationDatabaseImplement.csproj" />
</ItemGroup>
</Project>

View File

@ -1,5 +1,22 @@
@*
For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@{
@{
ViewData["Title"] = "Create";
}
<div class="text-center">
<h2 class="display-4">Создание ТО</h2>
</div>
<form method="post">
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="title" id="title" /></div>
</div>
<div class="row">
<div class="col-4">Цена:</div>
<div class="col-8"><input type="number" name="price" id="price" /></div>
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4">
<input type="submit" value="Создание" class="btn btn-primary" />
</div>
</div>
</form>

View File

@ -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<CarViewModel>
@{
ViewData["Title"] = "Home Page";
}
<div class="text-center">
<h1 class="display-4">ТО</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<p>
<a asp-action="Create">Создать ТО</a>
</p>
<table class="table">
<thead>
<tr>
<th>
Номер
</th>
<th>
Стоимость
</th>
<th>
Дата создания
</th>
<th>
Работник
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Brand)
</td>
<td>
@Html.DisplayFor(modelItem => item.Model)
</td>
<td>
@Html.DisplayFor(modelItem => item.VIN)
</td>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -8,11 +8,11 @@
<form method="post">
<div class="row">
<div class="col-4">Логин:</div>
<div class="col-8"><input type="text" name="fio" /></div>
<div class="col-8"><input type="text" name="login" /></div>
</div>
<div class="row">
<div class="col-4">Почта:</div>
<div class="col-8"><input type="text" name="login" /></div>
<div class="col-8"><input type="text" name="email" /></div>
</div>
<div class="row">
<div class="col-4">Пароль:</div>

View File

@ -23,7 +23,7 @@
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
<ul class="navbar-nav flex-grow-1">
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Станки</a>
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">ТО</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>