diff --git a/VetClinic/PharmacistApp/Program.cs b/VetClinic/PharmacistApp/Program.cs index 57900d3..934998a 100644 --- a/VetClinic/PharmacistApp/Program.cs +++ b/VetClinic/PharmacistApp/Program.cs @@ -7,7 +7,7 @@ builder.Services.AddControllersWithViews(); var app = builder.Build(); -APIPharmacist.Connect(builder.Configuration); +APIAdmin.Connect(builder.Configuration); // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) { diff --git a/VetClinic/VetClinic.sln b/VetClinic/VetClinic.sln index 04a42fb..14ba85c 100644 --- a/VetClinic/VetClinic.sln +++ b/VetClinic/VetClinic.sln @@ -13,9 +13,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicContracts", "VetCl EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicAdminApp", "VetClinicAdminApi\VetClinicAdminApp.csproj", "{75280728-CC4C-4C43-8921-2DC4AD8A9192}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VetClinicDataBaseImplement", "VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj", "{55D8A594-2412-49E5-B306-F7D0385A870D}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VetClinicDataBaseImplement", "VetClinicDataBaseImplement\VetClinicDataBaseImplement.csproj", "{55D8A594-2412-49E5-B306-F7D0385A870D}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PharmacistApp", "PharmacistApp\PharmacistApp.csproj", "{EF0A9AB0-6C45-4FC7-9A6E-91C064477CD5}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/VetClinic/VetClinicContracts/BindingModels/ServiceBindingModel.cs b/VetClinic/VetClinicContracts/BindingModels/ServiceBindingModel.cs index 2b25dee..bb7bf8f 100644 --- a/VetClinic/VetClinicContracts/BindingModels/ServiceBindingModel.cs +++ b/VetClinic/VetClinicContracts/BindingModels/ServiceBindingModel.cs @@ -1,4 +1,4 @@ -using Microsoft.Identity.Client; + using System; using System.Collections.Generic; using System.Linq; diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.cs deleted file mode 100644 index 9b9a2dd..0000000 --- a/VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.cs +++ /dev/null @@ -1,387 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace VetClinicDataBaseImplement.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Admins", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AdminFIO = 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_Admins", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Pharmacists", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PharmacistFIO = 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_Pharmacists", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Animals", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AdminId = table.Column(type: "int", nullable: false), - AnimalName = table.Column(type: "nvarchar(max)", nullable: false), - Family = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Animals", x => x.Id); - table.ForeignKey( - name: "FK_Animals_Admins_AdminId", - column: x => x.AdminId, - principalTable: "Admins", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Visits", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AdminId = table.Column(type: "int", nullable: false), - NameVisit = table.Column(type: "nvarchar(max)", nullable: false), - DateVisit = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Visits", x => x.Id); - table.ForeignKey( - name: "FK_Visits_Admins_AdminId", - column: x => x.AdminId, - principalTable: "Admins", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Medicines", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - MedicineName = table.Column(type: "nvarchar(max)", nullable: false), - PharmacistId = table.Column(type: "int", nullable: false), - Price = table.Column(type: "float", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Medicines", x => x.Id); - table.ForeignKey( - name: "FK_Medicines_Pharmacists_PharmacistId", - column: x => x.PharmacistId, - principalTable: "Pharmacists", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Services", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ServiceName = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - PharmacistId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Services", x => x.Id); - table.ForeignKey( - name: "FK_Services_Pharmacists_PharmacistId", - column: x => x.PharmacistId, - principalTable: "Pharmacists", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Vaccinations", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AnimalId = table.Column(type: "int", nullable: false), - NameVaccination = table.Column(type: "nvarchar(max)", nullable: false), - CostVaccination = table.Column(type: "float", nullable: false), - DateStamp = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Vaccinations", x => x.Id); - table.ForeignKey( - name: "FK_Vaccinations_Animals_AnimalId", - column: x => x.AnimalId, - principalTable: "Animals", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "VisitAnimals", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - AnimalId = table.Column(type: "int", nullable: false), - VisitId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_VisitAnimals", x => x.Id); - table.ForeignKey( - name: "FK_VisitAnimals_Animals_AnimalId", - column: x => x.AnimalId, - principalTable: "Animals", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_VisitAnimals_Visits_VisitId", - column: x => x.VisitId, - principalTable: "Visits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "MedicineAnimals", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - MedicineId = table.Column(type: "int", nullable: false), - AnimalId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_MedicineAnimals", x => x.Id); - table.ForeignKey( - name: "FK_MedicineAnimals_Animals_AnimalId", - column: x => x.AnimalId, - principalTable: "Animals", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_MedicineAnimals_Medicines_MedicineId", - column: x => x.MedicineId, - principalTable: "Medicines", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "Guidances", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ServiceId = table.Column(type: "int", nullable: false), - Text = table.Column(type: "nvarchar(max)", nullable: false), - Date = table.Column(type: "datetime2", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Guidances", x => x.Id); - table.ForeignKey( - name: "FK_Guidances_Services_ServiceId", - column: x => x.ServiceId, - principalTable: "Services", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ServiceMedicines", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ServiceId = table.Column(type: "int", nullable: false), - MedicineId = table.Column(type: "int", nullable: false), - Count = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ServiceMedicines", x => x.Id); - table.ForeignKey( - name: "FK_ServiceMedicines_Medicines_MedicineId", - column: x => x.MedicineId, - principalTable: "Medicines", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ServiceMedicines_Services_ServiceId", - column: x => x.ServiceId, - principalTable: "Services", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ServiceVisits", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ServiceId = table.Column(type: "int", nullable: false), - VisitId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ServiceVisits", x => x.Id); - table.ForeignKey( - name: "FK_ServiceVisits_Services_ServiceId", - column: x => x.ServiceId, - principalTable: "Services", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ServiceVisits_Visits_VisitId", - column: x => x.VisitId, - principalTable: "Visits", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_Animals_AdminId", - table: "Animals", - column: "AdminId"); - - migrationBuilder.CreateIndex( - name: "IX_Guidances_ServiceId", - table: "Guidances", - column: "ServiceId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicineAnimals_AnimalId", - table: "MedicineAnimals", - column: "AnimalId"); - - migrationBuilder.CreateIndex( - name: "IX_MedicineAnimals_MedicineId", - table: "MedicineAnimals", - column: "MedicineId"); - - migrationBuilder.CreateIndex( - name: "IX_Medicines_PharmacistId", - table: "Medicines", - column: "PharmacistId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceMedicines_MedicineId", - table: "ServiceMedicines", - column: "MedicineId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceMedicines_ServiceId", - table: "ServiceMedicines", - column: "ServiceId"); - - migrationBuilder.CreateIndex( - name: "IX_Services_PharmacistId", - table: "Services", - column: "PharmacistId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceVisits_ServiceId", - table: "ServiceVisits", - column: "ServiceId"); - - migrationBuilder.CreateIndex( - name: "IX_ServiceVisits_VisitId", - table: "ServiceVisits", - column: "VisitId"); - - migrationBuilder.CreateIndex( - name: "IX_Vaccinations_AnimalId", - table: "Vaccinations", - column: "AnimalId"); - - migrationBuilder.CreateIndex( - name: "IX_VisitAnimals_AnimalId", - table: "VisitAnimals", - column: "AnimalId"); - - migrationBuilder.CreateIndex( - name: "IX_VisitAnimals_VisitId", - table: "VisitAnimals", - column: "VisitId"); - - migrationBuilder.CreateIndex( - name: "IX_Visits_AdminId", - table: "Visits", - column: "AdminId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "Guidances"); - - migrationBuilder.DropTable( - name: "MedicineAnimals"); - - migrationBuilder.DropTable( - name: "ServiceMedicines"); - - migrationBuilder.DropTable( - name: "ServiceVisits"); - - migrationBuilder.DropTable( - name: "Vaccinations"); - - migrationBuilder.DropTable( - name: "VisitAnimals"); - - migrationBuilder.DropTable( - name: "Medicines"); - - migrationBuilder.DropTable( - name: "Services"); - - migrationBuilder.DropTable( - name: "Animals"); - - migrationBuilder.DropTable( - name: "Visits"); - - migrationBuilder.DropTable( - name: "Pharmacists"); - - migrationBuilder.DropTable( - name: "Admins"); - } - } -} diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.Designer.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.Designer.cs similarity index 99% rename from VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.Designer.cs rename to VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.Designer.cs index e35e389..f4265dc 100644 --- a/VetClinic/VetClinicDataBaseImplement/Migrations/20240427064357_InitialCreate.Designer.cs +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using VetClinicDataBaseImplement; namespace VetClinicDataBaseImplement.Migrations { [DbContext(typeof(VetClinicDatabase))] - [Migration("20240427064357_InitialCreate")] + [Migration("20240427074910_InitialCreate")] partial class InitialCreate { /// diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.cs new file mode 100644 index 0000000..ddaba24 --- /dev/null +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/20240427074910_InitialCreate.cs @@ -0,0 +1,387 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace VetClinicDataBaseImplement.Migrations +{ + /// + public partial class InitialCreate : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Admins", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminFIO = 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_Admins", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Pharmacists", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + PharmacistFIO = 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_Pharmacists", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "Animals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminId = table.Column(type: "int", nullable: false), + AnimalName = table.Column(type: "nvarchar(max)", nullable: false), + Family = table.Column(type: "nvarchar(max)", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Animals", x => x.Id); + table.ForeignKey( + name: "FK_Animals_Admins_AdminId", + column: x => x.AdminId, + principalTable: "Admins", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Visits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AdminId = table.Column(type: "int", nullable: false), + NameVisit = table.Column(type: "nvarchar(max)", nullable: false), + DateVisit = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Visits", x => x.Id); + table.ForeignKey( + name: "FK_Visits_Admins_AdminId", + column: x => x.AdminId, + principalTable: "Admins", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Medicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MedicineName = table.Column(type: "nvarchar(max)", nullable: false), + PharmacistId = table.Column(type: "int", nullable: false), + Price = table.Column(type: "float", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Medicines", x => x.Id); + table.ForeignKey( + name: "FK_Medicines_Pharmacists_PharmacistId", + column: x => x.PharmacistId, + principalTable: "Pharmacists", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Services", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceName = table.Column(type: "nvarchar(max)", nullable: false), + Price = table.Column(type: "float", nullable: false), + PharmacistId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Services", x => x.Id); + table.ForeignKey( + name: "FK_Services_Pharmacists_PharmacistId", + column: x => x.PharmacistId, + principalTable: "Pharmacists", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateTable( + name: "Vaccinations", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AnimalId = table.Column(type: "int", nullable: false), + NameVaccination = table.Column(type: "nvarchar(max)", nullable: false), + CostVaccination = table.Column(type: "float", nullable: false), + DateStamp = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Vaccinations", x => x.Id); + table.ForeignKey( + name: "FK_Vaccinations_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "VisitAnimals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + AnimalId = table.Column(type: "int", nullable: false), + VisitId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_VisitAnimals", x => x.Id); + table.ForeignKey( + name: "FK_VisitAnimals_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_VisitAnimals_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "MedicineAnimals", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + MedicineId = table.Column(type: "int", nullable: false), + AnimalId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_MedicineAnimals", x => x.Id); + table.ForeignKey( + name: "FK_MedicineAnimals_Animals_AnimalId", + column: x => x.AnimalId, + principalTable: "Animals", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_MedicineAnimals_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Guidances", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + Text = table.Column(type: "nvarchar(max)", nullable: false), + Date = table.Column(type: "datetime2", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Guidances", x => x.Id); + table.ForeignKey( + name: "FK_Guidances_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ServiceMedicines", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + MedicineId = table.Column(type: "int", nullable: false), + Count = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ServiceMedicines", x => x.Id); + table.ForeignKey( + name: "FK_ServiceMedicines_Medicines_MedicineId", + column: x => x.MedicineId, + principalTable: "Medicines", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ServiceMedicines_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "ServiceVisits", + columns: table => new + { + Id = table.Column(type: "int", nullable: false) + .Annotation("SqlServer:Identity", "1, 1"), + ServiceId = table.Column(type: "int", nullable: false), + VisitId = table.Column(type: "int", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ServiceVisits", x => x.Id); + table.ForeignKey( + name: "FK_ServiceVisits_Services_ServiceId", + column: x => x.ServiceId, + principalTable: "Services", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ServiceVisits_Visits_VisitId", + column: x => x.VisitId, + principalTable: "Visits", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_Animals_AdminId", + table: "Animals", + column: "AdminId"); + + migrationBuilder.CreateIndex( + name: "IX_Guidances_ServiceId", + table: "Guidances", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicineAnimals_AnimalId", + table: "MedicineAnimals", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_MedicineAnimals_MedicineId", + table: "MedicineAnimals", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_Medicines_PharmacistId", + table: "Medicines", + column: "PharmacistId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceMedicines_MedicineId", + table: "ServiceMedicines", + column: "MedicineId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceMedicines_ServiceId", + table: "ServiceMedicines", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_Services_PharmacistId", + table: "Services", + column: "PharmacistId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceVisits_ServiceId", + table: "ServiceVisits", + column: "ServiceId"); + + migrationBuilder.CreateIndex( + name: "IX_ServiceVisits_VisitId", + table: "ServiceVisits", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Vaccinations_AnimalId", + table: "Vaccinations", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_AnimalId", + table: "VisitAnimals", + column: "AnimalId"); + + migrationBuilder.CreateIndex( + name: "IX_VisitAnimals_VisitId", + table: "VisitAnimals", + column: "VisitId"); + + migrationBuilder.CreateIndex( + name: "IX_Visits_AdminId", + table: "Visits", + column: "AdminId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "Guidances"); + + migrationBuilder.DropTable( + name: "MedicineAnimals"); + + migrationBuilder.DropTable( + name: "ServiceMedicines"); + + migrationBuilder.DropTable( + name: "ServiceVisits"); + + migrationBuilder.DropTable( + name: "Vaccinations"); + + migrationBuilder.DropTable( + name: "VisitAnimals"); + + migrationBuilder.DropTable( + name: "Medicines"); + + migrationBuilder.DropTable( + name: "Services"); + + migrationBuilder.DropTable( + name: "Animals"); + + migrationBuilder.DropTable( + name: "Visits"); + + migrationBuilder.DropTable( + name: "Pharmacists"); + + migrationBuilder.DropTable( + name: "Admins"); + } + } +} diff --git a/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs b/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs index 926d7c4..0e143f8 100644 --- a/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs +++ b/VetClinic/VetClinicDataBaseImplement/Migrations/VetClinicDatabaseModelSnapshot.cs @@ -10,506 +10,506 @@ using VetClinicDataBaseImplement; namespace VetClinicDataBaseImplement.Migrations { - [DbContext(typeof(VetClinicDatabase))] - partial class VetClinicDatabaseModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { + [DbContext(typeof(VetClinicDatabase))] + partial class VetClinicDatabaseModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { #pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "8.0.4") - .HasAnnotation("Relational:MaxIdentifierLength", 128); + modelBuilder + .HasAnnotation("ProductVersion", "8.0.4") + .HasAnnotation("Relational:MaxIdentifierLength", 128); - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AdminFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("AdminFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Admins"); - }); + b.ToTable("Admins"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AdminId") - .HasColumnType("int"); + b.Property("AdminId") + .HasColumnType("int"); - b.Property("AnimalName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("AnimalName") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Family") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Family") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AdminId"); + b.HasIndex("AdminId"); - b.ToTable("Animals"); - }); + b.ToTable("Animals"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Date") - .HasColumnType("datetime2"); + b.Property("Date") + .HasColumnType("datetime2"); - b.Property("ServiceId") - .HasColumnType("int"); + b.Property("ServiceId") + .HasColumnType("int"); - b.Property("Text") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Text") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ServiceId"); + b.HasIndex("ServiceId"); - b.ToTable("Guidances"); - }); + b.ToTable("Guidances"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("MedicineName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("MedicineName") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("PharmacistId") - .HasColumnType("int"); + b.Property("PharmacistId") + .HasColumnType("int"); - b.Property("Price") - .HasColumnType("float"); + b.Property("Price") + .HasColumnType("float"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("PharmacistId"); + b.HasIndex("PharmacistId"); - b.ToTable("Medicines"); - }); + b.ToTable("Medicines"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AnimalId") - .HasColumnType("int"); + b.Property("AnimalId") + .HasColumnType("int"); - b.Property("MedicineId") - .HasColumnType("int"); + b.Property("MedicineId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AnimalId"); + b.HasIndex("AnimalId"); - b.HasIndex("MedicineId"); + b.HasIndex("MedicineId"); - b.ToTable("MedicineAnimals"); - }); + b.ToTable("MedicineAnimals"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Email") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("Password") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.Property("PharmacistFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("PharmacistFIO") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.ToTable("Pharmacists"); - }); + b.ToTable("Pharmacists"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("PharmacistId") - .HasColumnType("int"); + b.Property("PharmacistId") + .HasColumnType("int"); - b.Property("Price") - .HasColumnType("float"); + b.Property("Price") + .HasColumnType("float"); - b.Property("ServiceName") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("ServiceName") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("PharmacistId"); + b.HasIndex("PharmacistId"); - b.ToTable("Services"); - }); + b.ToTable("Services"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("Count") - .HasColumnType("int"); + b.Property("Count") + .HasColumnType("int"); - b.Property("MedicineId") - .HasColumnType("int"); + b.Property("MedicineId") + .HasColumnType("int"); - b.Property("ServiceId") - .HasColumnType("int"); + b.Property("ServiceId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("MedicineId"); + b.HasIndex("MedicineId"); - b.HasIndex("ServiceId"); + b.HasIndex("ServiceId"); - b.ToTable("ServiceMedicines"); - }); + b.ToTable("ServiceMedicines"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AnimalId") - .HasColumnType("int"); + b.Property("AnimalId") + .HasColumnType("int"); - b.Property("CostVaccination") - .HasColumnType("float"); + b.Property("CostVaccination") + .HasColumnType("float"); - b.Property("DateStamp") - .IsRequired() - .HasColumnType("datetime2"); + b.Property("DateStamp") + .IsRequired() + .HasColumnType("datetime2"); - b.Property("NameVaccination") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("NameVaccination") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AnimalId"); + b.HasIndex("AnimalId"); - b.ToTable("Vaccinations"); - }); + b.ToTable("Vaccinations"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AdminId") - .HasColumnType("int"); + b.Property("AdminId") + .HasColumnType("int"); - b.Property("DateVisit") - .HasColumnType("datetime2"); + b.Property("DateVisit") + .HasColumnType("datetime2"); - b.Property("NameVisit") - .IsRequired() - .HasColumnType("nvarchar(max)"); + b.Property("NameVisit") + .IsRequired() + .HasColumnType("nvarchar(max)"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AdminId"); + b.HasIndex("AdminId"); - b.ToTable("Visits"); - }); + b.ToTable("Visits"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("AnimalId") - .HasColumnType("int"); + b.Property("AnimalId") + .HasColumnType("int"); - b.Property("VisitId") - .HasColumnType("int"); + b.Property("VisitId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("AnimalId"); + b.HasIndex("AnimalId"); - b.HasIndex("VisitId"); + b.HasIndex("VisitId"); - b.ToTable("VisitAnimals"); - }); + b.ToTable("VisitAnimals"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("int"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ServiceId") - .HasColumnType("int"); + b.Property("ServiceId") + .HasColumnType("int"); - b.Property("VisitId") - .HasColumnType("int"); + b.Property("VisitId") + .HasColumnType("int"); - b.HasKey("Id"); + b.HasKey("Id"); - b.HasIndex("ServiceId"); + b.HasIndex("ServiceId"); - b.HasIndex("VisitId"); + b.HasIndex("VisitId"); - b.ToTable("ServiceVisits"); - }); + b.ToTable("ServiceVisits"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") - .WithMany("Animals") - .HasForeignKey("AdminId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Animals") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Admin"); - }); + b.Navigation("Admin"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") - .WithMany("Guidances") - .HasForeignKey("ServiceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Guidance", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Guidances") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.Navigation("Service"); - }); + b.Navigation("Service"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") - .WithMany("Medicines") - .HasForeignKey("PharmacistId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Pharmacist"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") - .WithMany("Medicines") - .HasForeignKey("AnimalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") - .WithMany("Animals") - .HasForeignKey("MedicineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Animal"); - - b.Navigation("Medicine"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") - .WithMany("Services") - .HasForeignKey("PharmacistId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Pharmacist"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") - .WithMany("Services") - .HasForeignKey("MedicineId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") - .WithMany("Medicines") - .HasForeignKey("ServiceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Medicine"); - - b.Navigation("Service"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") - .WithMany("Vaccinations") - .HasForeignKey("AnimalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Animal"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") - .WithMany("Visits") - .HasForeignKey("AdminId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Admin"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") - .WithMany("Visits") - .HasForeignKey("AnimalId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") - .WithMany("Animals") - .HasForeignKey("VisitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Animal"); - - b.Navigation("Visit"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => - { - b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") - .WithMany("Visits") - .HasForeignKey("ServiceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") - .WithMany("Services") - .HasForeignKey("VisitId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Service"); - - b.Navigation("Visit"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => - { - b.Navigation("Animals"); - - b.Navigation("Visits"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => - { - b.Navigation("Medicines"); - - b.Navigation("Vaccinations"); - - b.Navigation("Visits"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => - { - b.Navigation("Animals"); - - b.Navigation("Services"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => - { - b.Navigation("Medicines"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Medicines") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.MedicineAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Medicines") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Animals") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Medicine"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Pharmacist", "Pharmacist") + .WithMany("Services") + .HasForeignKey("PharmacistId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Pharmacist"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.ServiceMedicine", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Medicine", "Medicine") + .WithMany("Services") + .HasForeignKey("MedicineId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Medicines") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Medicine"); + + b.Navigation("Service"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Vaccination", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Vaccinations") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Admin", "Admin") + .WithMany("Visits") + .HasForeignKey("AdminId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Admin"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitAnimal", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Animal", "Animal") + .WithMany("Visits") + .HasForeignKey("AnimalId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Animals") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Animal"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.VisitService", b => + { + b.HasOne("VetClinicDataBaseImplement.Models.Service", "Service") + .WithMany("Visits") + .HasForeignKey("ServiceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("VetClinicDataBaseImplement.Models.Visit", "Visit") + .WithMany("Services") + .HasForeignKey("VisitId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Service"); + + b.Navigation("Visit"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Admin", b => + { + b.Navigation("Animals"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Animal", b => + { + b.Navigation("Medicines"); + + b.Navigation("Vaccinations"); + + b.Navigation("Visits"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Medicine", b => + { + b.Navigation("Animals"); + + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Pharmacist", b => + { + b.Navigation("Medicines"); - b.Navigation("Services"); - }); - - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => - { - b.Navigation("Guidances"); + b.Navigation("Services"); + }); + + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Service", b => + { + b.Navigation("Guidances"); - b.Navigation("Medicines"); + b.Navigation("Medicines"); - b.Navigation("Visits"); - }); + b.Navigation("Visits"); + }); - modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => - { - b.Navigation("Animals"); + modelBuilder.Entity("VetClinicDataBaseImplement.Models.Visit", b => + { + b.Navigation("Animals"); - b.Navigation("Services"); - }); + b.Navigation("Services"); + }); #pragma warning restore 612, 618 - } - } + } + } } diff --git a/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs b/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs new file mode 100644 index 0000000..9f85853 --- /dev/null +++ b/VetClinic/VetClinicRestApi/Controllers/AnimalContoller.cs @@ -0,0 +1,96 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using VetClinicContracts.BindingModels; +using VetClinicContracts.BusinessLogicsContracts; +using VetClinicContracts.SearchModels; +using VetClinicContracts.ViewModels; + +namespace VetClinicRestApi.Controllers +{ + [Route("api/[controller]/[action]")] + [ApiController] + public class AnimalController : Controller + { + private readonly ILogger _logger; + private readonly IAnimalLogic _animal; + public AnimalController(ILogger logger, IAnimalLogic animal) + { + _logger = logger; + _animal = animal; + } + + [HttpGet] + public AnimalViewModel? GetAnimal(int animalId) + { + try + { + return _animal.ReadElement(new AnimalSearchModel + { + Id = animalId + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения животного по id={Id}", animalId); + throw; + } + } + + [HttpGet] + public List? GetAnimalList() + { + try + { + return _animal.ReadList(null); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка получения списка животного"); + throw; + } + } + [HttpPost] + public bool CreateAnimal(AnimalBindingModel model) + { + try + { + return _animal.CreateAnimal(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Не удалось создать животное"); + throw; + } + } + + [HttpPost] + public bool UpdateAnimal(AnimalBindingModel model) + { + try + { + return _animal.UpdateAnimal(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Не удалось обновить животное"); + throw; + } + } + + [HttpPost] + public bool DeleteAnimal(AnimalBindingModel model) + { + try + { + return _animal.DeleteAnimal(model); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления услуги"); + throw; + } + } + + + } +}