diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.Designer.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.Designer.cs deleted file mode 100644 index df19cd7..0000000 --- a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.Designer.cs +++ /dev/null @@ -1,444 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using TravelAgencyDatabaseImplement; - -#nullable disable - -namespace TravelAgencyDatabaseImplement.Migrations -{ - [DbContext(typeof(TravelAgencyDatabase))] - [Migration("20240429171656_InitialCreate")] - partial class InitialCreate - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.18") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionDescription") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ExcursionName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Excursions"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionGroupName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GuideId") - .HasColumnType("int"); - - b.Property("ParticipantsAmount") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("GuideId"); - - b.HasIndex("UserId"); - - b.ToTable("ExcursionGroups"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionGroupId") - .HasColumnType("int"); - - b.Property("TourId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionGroupId"); - - b.HasIndex("TourId"); - - b.ToTable("ExcursionGroupTours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionId") - .HasColumnType("int"); - - b.Property("TourId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionId"); - - b.HasIndex("TourId"); - - b.ToTable("ExcursionTours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GuideFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Guides"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionId") - .HasColumnType("int"); - - b.Property("PlaceAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PlaceName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionId"); - - b.ToTable("Places"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("TourDate") - .HasColumnType("datetime2"); - - b.Property("TourDescription") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TourName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("GuideId") - .HasColumnType("int"); - - b.Property("TripDate") - .HasColumnType("datetime2"); - - b.Property("TripName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("GuideId"); - - b.ToTable("Trips"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PlaceId") - .HasColumnType("int"); - - b.Property("TripId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("PlaceId"); - - b.HasIndex("TripId"); - - b.ToTable("TripPlaces"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() - .HasForeignKey("GuideId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Guide"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup") - .WithMany("Tours") - .HasForeignKey("ExcursionGroupId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour") - .WithMany("ExcursionGroups") - .HasForeignKey("TourId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExcursionGroup"); - - b.Navigation("Tour"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany("Tours") - .HasForeignKey("ExcursionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour") - .WithMany("Excursions") - .HasForeignKey("TourId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Excursion"); - - b.Navigation("Tour"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany("Places") - .HasForeignKey("ExcursionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Excursion"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() - .HasForeignKey("GuideId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Guide"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place") - .WithMany("Trips") - .HasForeignKey("PlaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Trip", "Trip") - .WithMany("Places") - .HasForeignKey("TripId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Place"); - - b.Navigation("Trip"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.Navigation("Places"); - - b.Navigation("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.Navigation("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.Navigation("Trips"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.Navigation("ExcursionGroups"); - - b.Navigation("Excursions"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.Navigation("Places"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.cs deleted file mode 100644 index 762d552..0000000 --- a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429171656_InitialCreate.cs +++ /dev/null @@ -1,333 +0,0 @@ -using System; -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace TravelAgencyDatabaseImplement.Migrations -{ - /// - public partial class InitialCreate : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - migrationBuilder.CreateTable( - name: "Guides", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - GuideFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Guides", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Users", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - UserFIO = table.Column(type: "nvarchar(max)", nullable: false), - Email = table.Column(type: "nvarchar(max)", nullable: false), - PhoneNumber = table.Column(type: "nvarchar(max)", nullable: false), - Password = table.Column(type: "nvarchar(max)", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Users", x => x.Id); - }); - - migrationBuilder.CreateTable( - name: "Trips", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - TripName = table.Column(type: "nvarchar(max)", nullable: false), - TripDate = table.Column(type: "datetime2", nullable: false), - GuideId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Trips", x => x.Id); - table.ForeignKey( - name: "FK_Trips_Guides_GuideId", - column: x => x.GuideId, - principalTable: "Guides", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ExcursionGroups", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ExcursionGroupName = table.Column(type: "nvarchar(max)", nullable: false), - ParticipantsAmount = table.Column(type: "int", nullable: false), - UserId = table.Column(type: "int", nullable: false), - GuideId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ExcursionGroups", x => x.Id); - table.ForeignKey( - name: "FK_ExcursionGroups_Guides_GuideId", - column: x => x.GuideId, - principalTable: "Guides", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ExcursionGroups_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Excursions", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ExcursionName = table.Column(type: "nvarchar(max)", nullable: false), - ExcursionDescription = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - UserId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Excursions", x => x.Id); - table.ForeignKey( - name: "FK_Excursions_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Tours", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - TourName = table.Column(type: "nvarchar(max)", nullable: false), - TourDescription = table.Column(type: "nvarchar(max)", nullable: false), - Price = table.Column(type: "float", nullable: false), - TourDate = table.Column(type: "datetime2", nullable: false), - UserId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Tours", x => x.Id); - table.ForeignKey( - name: "FK_Tours_Users_UserId", - column: x => x.UserId, - principalTable: "Users", - principalColumn: "Id", - onDelete: ReferentialAction.Restrict); - }); - - migrationBuilder.CreateTable( - name: "Places", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - PlaceName = table.Column(type: "nvarchar(max)", nullable: false), - PlaceAddress = table.Column(type: "nvarchar(max)", nullable: false), - ExcursionId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_Places", x => x.Id); - table.ForeignKey( - name: "FK_Places_Excursions_ExcursionId", - column: x => x.ExcursionId, - principalTable: "Excursions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ExcursionGroupTours", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ExcursionGroupId = table.Column(type: "int", nullable: false), - TourId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ExcursionGroupTours", x => x.Id); - table.ForeignKey( - name: "FK_ExcursionGroupTours_ExcursionGroups_ExcursionGroupId", - column: x => x.ExcursionGroupId, - principalTable: "ExcursionGroups", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ExcursionGroupTours_Tours_TourId", - column: x => x.TourId, - principalTable: "Tours", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "ExcursionTours", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - ExcursionId = table.Column(type: "int", nullable: false), - TourId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_ExcursionTours", x => x.Id); - table.ForeignKey( - name: "FK_ExcursionTours_Excursions_ExcursionId", - column: x => x.ExcursionId, - principalTable: "Excursions", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_ExcursionTours_Tours_TourId", - column: x => x.TourId, - principalTable: "Tours", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateTable( - name: "TripPlaces", - columns: table => new - { - Id = table.Column(type: "int", nullable: false) - .Annotation("SqlServer:Identity", "1, 1"), - TripId = table.Column(type: "int", nullable: false), - PlaceId = table.Column(type: "int", nullable: false) - }, - constraints: table => - { - table.PrimaryKey("PK_TripPlaces", x => x.Id); - table.ForeignKey( - name: "FK_TripPlaces_Places_PlaceId", - column: x => x.PlaceId, - principalTable: "Places", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - table.ForeignKey( - name: "FK_TripPlaces_Trips_TripId", - column: x => x.TripId, - principalTable: "Trips", - principalColumn: "Id", - onDelete: ReferentialAction.Cascade); - }); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionGroups_GuideId", - table: "ExcursionGroups", - column: "GuideId"); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionGroups_UserId", - table: "ExcursionGroups", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionGroupTours_ExcursionGroupId", - table: "ExcursionGroupTours", - column: "ExcursionGroupId"); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionGroupTours_TourId", - table: "ExcursionGroupTours", - column: "TourId"); - - migrationBuilder.CreateIndex( - name: "IX_Excursions_UserId", - table: "Excursions", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionTours_ExcursionId", - table: "ExcursionTours", - column: "ExcursionId"); - - migrationBuilder.CreateIndex( - name: "IX_ExcursionTours_TourId", - table: "ExcursionTours", - column: "TourId"); - - migrationBuilder.CreateIndex( - name: "IX_Places_ExcursionId", - table: "Places", - column: "ExcursionId"); - - migrationBuilder.CreateIndex( - name: "IX_Tours_UserId", - table: "Tours", - column: "UserId"); - - migrationBuilder.CreateIndex( - name: "IX_TripPlaces_PlaceId", - table: "TripPlaces", - column: "PlaceId"); - - migrationBuilder.CreateIndex( - name: "IX_TripPlaces_TripId", - table: "TripPlaces", - column: "TripId"); - - migrationBuilder.CreateIndex( - name: "IX_Trips_GuideId", - table: "Trips", - column: "GuideId"); - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - migrationBuilder.DropTable( - name: "ExcursionGroupTours"); - - migrationBuilder.DropTable( - name: "ExcursionTours"); - - migrationBuilder.DropTable( - name: "TripPlaces"); - - migrationBuilder.DropTable( - name: "ExcursionGroups"); - - migrationBuilder.DropTable( - name: "Tours"); - - migrationBuilder.DropTable( - name: "Places"); - - migrationBuilder.DropTable( - name: "Trips"); - - migrationBuilder.DropTable( - name: "Excursions"); - - migrationBuilder.DropTable( - name: "Guides"); - - migrationBuilder.DropTable( - name: "Users"); - } - } -} diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs deleted file mode 100644 index 31952e2..0000000 --- a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs +++ /dev/null @@ -1,441 +0,0 @@ -// -using System; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; -using TravelAgencyDatabaseImplement; - -#nullable disable - -namespace TravelAgencyDatabaseImplement.Migrations -{ - [DbContext(typeof(TravelAgencyDatabase))] - partial class TravelAgencyDatabaseModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "7.0.18") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionDescription") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("ExcursionName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Excursions"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionGroupName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GuideId") - .HasColumnType("int"); - - b.Property("ParticipantsAmount") - .HasColumnType("int"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("GuideId"); - - b.HasIndex("UserId"); - - b.ToTable("ExcursionGroups"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionGroupId") - .HasColumnType("int"); - - b.Property("TourId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionGroupId"); - - b.HasIndex("TourId"); - - b.ToTable("ExcursionGroupTours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionId") - .HasColumnType("int"); - - b.Property("TourId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionId"); - - b.HasIndex("TourId"); - - b.ToTable("ExcursionTours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("GuideFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Guides"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("ExcursionId") - .HasColumnType("int"); - - b.Property("PlaceAddress") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PlaceName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("ExcursionId"); - - b.ToTable("Places"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Price") - .HasColumnType("float"); - - b.Property("TourDate") - .HasColumnType("datetime2"); - - b.Property("TourDescription") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("TourName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("GuideId") - .HasColumnType("int"); - - b.Property("TripDate") - .HasColumnType("datetime2"); - - b.Property("TripName") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.HasIndex("GuideId"); - - b.ToTable("Trips"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("PlaceId") - .HasColumnType("int"); - - b.Property("TripId") - .HasColumnType("int"); - - b.HasKey("Id"); - - b.HasIndex("PlaceId"); - - b.HasIndex("TripId"); - - b.ToTable("TripPlaces"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b => - { - b.Property("Id") - .ValueGeneratedOnAdd() - .HasColumnType("int"); - - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - - b.Property("Email") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("Password") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("PhoneNumber") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.Property("UserFIO") - .IsRequired() - .HasColumnType("nvarchar(max)"); - - b.HasKey("Id"); - - b.ToTable("Users"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() - .HasForeignKey("GuideId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("Guide"); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroupTour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.ExcursionGroup", "ExcursionGroup") - .WithMany("Tours") - .HasForeignKey("ExcursionGroupId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour") - .WithMany("ExcursionGroups") - .HasForeignKey("TourId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("ExcursionGroup"); - - b.Navigation("Tour"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionTour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany("Tours") - .HasForeignKey("ExcursionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Tour", "Tour") - .WithMany("Excursions") - .HasForeignKey("TourId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Excursion"); - - b.Navigation("Tour"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany("Places") - .HasForeignKey("ExcursionId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Excursion"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Restrict) - .IsRequired(); - - b.Navigation("User"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() - .HasForeignKey("GuideId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Guide"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.TripPlace", b => - { - b.HasOne("TravelAgencyDatabaseImplement.Models.Place", "Place") - .WithMany("Trips") - .HasForeignKey("PlaceId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.HasOne("TravelAgencyDatabaseImplement.Models.Trip", "Trip") - .WithMany("Places") - .HasForeignKey("TripId") - .OnDelete(DeleteBehavior.Cascade) - .IsRequired(); - - b.Navigation("Place"); - - b.Navigation("Trip"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => - { - b.Navigation("Places"); - - b.Navigation("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => - { - b.Navigation("Tours"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => - { - b.Navigation("Trips"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => - { - b.Navigation("ExcursionGroups"); - - b.Navigation("Excursions"); - }); - - modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => - { - b.Navigation("Places"); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs index d83d9cf..f81ad60 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs @@ -1,5 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; @@ -22,7 +21,6 @@ namespace TravelAgencyDatabaseImplement.Models [Required] public int UserId { get; set; } - [DeleteBehavior(DeleteBehavior.Restrict)] public virtual User User { get; set; } private Dictionary? _excursionTours = null; @@ -44,9 +42,6 @@ namespace TravelAgencyDatabaseImplement.Models [ForeignKey("ExcursionId")] public virtual List Tours { get; set; } = new(); - [ForeignKey("ExcursionId")] - public virtual List Places { get; set; } = new(); - public static Excursion? Create(TravelAgencyDatabase context, ExcursionBindingModel? model) { if (model == null) diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs index f8dc21e..f12a4df 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/ExcursionGroup.cs @@ -3,7 +3,6 @@ using System.ComponentModel.DataAnnotations; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; using TravelAgencyDataModels.Models; -using Microsoft.EntityFrameworkCore; namespace TravelAgencyDatabaseImplement.Models { @@ -20,14 +19,13 @@ namespace TravelAgencyDatabaseImplement.Models [Required] public int UserId { get; set; } - [DeleteBehavior(DeleteBehavior.Restrict)] - public virtual User User { get; set; } - [Required] public int GuideId { get; set; } public virtual Guide Guide { get; set; } + public virtual User User { get; set; } + private Dictionary? _excursionGroupTours = null; [NotMapped] diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/Tour.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/Tour.cs index f402385..1f9d94d 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/Tour.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/Tour.cs @@ -1,5 +1,4 @@ -using Microsoft.EntityFrameworkCore; -using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations.Schema; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; @@ -25,7 +24,6 @@ namespace TravelAgencyDatabaseImplement.Models [Required] public int UserId { get; set; } - [DeleteBehavior(DeleteBehavior.Restrict)] public virtual User User { get; set; } [ForeignKey("TourId")] diff --git a/TravelAgency/TravelAgencyDatabaseImplement/TravelAgencyDatabaseImplement.csproj b/TravelAgency/TravelAgencyDatabaseImplement/TravelAgencyDatabaseImplement.csproj index 0b5b5dc..312e9a9 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/TravelAgencyDatabaseImplement.csproj +++ b/TravelAgency/TravelAgencyDatabaseImplement/TravelAgencyDatabaseImplement.csproj @@ -7,9 +7,9 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive