From cc9d05ccf5b1bd065d6c307b988b066e6938281e Mon Sep 17 00:00:00 2001 From: russell Date: Mon, 29 Apr 2024 21:56:45 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=81=D0=B2=D1=8F?= =?UTF-8?q?=D0=B7=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ... 20240429175309_InitialCreate.Designer.cs} | 32 +++++++++++++++---- ...ate.cs => 20240429175309_InitialCreate.cs} | 0 .../TravelAgencyDatabaseModelSnapshot.cs | 30 +++++++++++++---- .../Models/Excursion.cs | 3 ++ .../Models/Guide.cs | 7 ++++ .../Models/User.cs | 10 ++++++ 6 files changed, 69 insertions(+), 13 deletions(-) rename TravelAgency/TravelAgencyDatabaseImplement/Migrations/{20240429172546_InitialCreate.Designer.cs => 20240429175309_InitialCreate.Designer.cs} (94%) rename TravelAgency/TravelAgencyDatabaseImplement/Migrations/{20240429172546_InitialCreate.cs => 20240429175309_InitialCreate.cs} (100%) diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429172546_InitialCreate.Designer.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429175309_InitialCreate.Designer.cs similarity index 94% rename from TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429172546_InitialCreate.Designer.cs rename to TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429175309_InitialCreate.Designer.cs index 8ab879c..82568c4 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429172546_InitialCreate.Designer.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429175309_InitialCreate.Designer.cs @@ -12,7 +12,7 @@ using TravelAgencyDatabaseImplement; namespace TravelAgencyDatabaseImplement.Migrations { [DbContext(typeof(TravelAgencyDatabase))] - [Migration("20240429172546_InitialCreate")] + [Migration("20240429175309_InitialCreate")] partial class InitialCreate { /// @@ -293,7 +293,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("Excursions") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -304,13 +304,13 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() + .WithMany("ExcursionGroups") .HasForeignKey("GuideId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("ExcursionGroups") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -361,7 +361,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany() + .WithMany("Places") .HasForeignKey("ExcursionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -372,7 +372,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("Tours") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -383,7 +383,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() + .WithMany("Trips") .HasForeignKey("GuideId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -412,6 +412,8 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => { + b.Navigation("Places"); + b.Navigation("Tours"); }); @@ -420,6 +422,13 @@ namespace TravelAgencyDatabaseImplement.Migrations b.Navigation("Tours"); }); + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b => + { + b.Navigation("ExcursionGroups"); + + b.Navigation("Trips"); + }); + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => { b.Navigation("Trips"); @@ -436,6 +445,15 @@ namespace TravelAgencyDatabaseImplement.Migrations { b.Navigation("Places"); }); + + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b => + { + b.Navigation("ExcursionGroups"); + + b.Navigation("Excursions"); + + b.Navigation("Tours"); + }); #pragma warning restore 612, 618 } } diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429172546_InitialCreate.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429175309_InitialCreate.cs similarity index 100% rename from TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429172546_InitialCreate.cs rename to TravelAgency/TravelAgencyDatabaseImplement/Migrations/20240429175309_InitialCreate.cs diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs index 86eba00..249d06e 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Migrations/TravelAgencyDatabaseModelSnapshot.cs @@ -290,7 +290,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("Excursions") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -301,13 +301,13 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.ExcursionGroup", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() + .WithMany("ExcursionGroups") .HasForeignKey("GuideId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("ExcursionGroups") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -358,7 +358,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Excursion", "Excursion") - .WithMany() + .WithMany("Places") .HasForeignKey("ExcursionId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -369,7 +369,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Tour", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.User", "User") - .WithMany() + .WithMany("Tours") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Restrict) .IsRequired(); @@ -380,7 +380,7 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Trip", b => { b.HasOne("TravelAgencyDatabaseImplement.Models.Guide", "Guide") - .WithMany() + .WithMany("Trips") .HasForeignKey("GuideId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); @@ -409,6 +409,8 @@ namespace TravelAgencyDatabaseImplement.Migrations modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Excursion", b => { + b.Navigation("Places"); + b.Navigation("Tours"); }); @@ -417,6 +419,13 @@ namespace TravelAgencyDatabaseImplement.Migrations b.Navigation("Tours"); }); + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Guide", b => + { + b.Navigation("ExcursionGroups"); + + b.Navigation("Trips"); + }); + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.Place", b => { b.Navigation("Trips"); @@ -433,6 +442,15 @@ namespace TravelAgencyDatabaseImplement.Migrations { b.Navigation("Places"); }); + + modelBuilder.Entity("TravelAgencyDatabaseImplement.Models.User", b => + { + b.Navigation("ExcursionGroups"); + + b.Navigation("Excursions"); + + b.Navigation("Tours"); + }); #pragma warning restore 612, 618 } } diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs index 9ca2663..d83d9cf 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/Excursion.cs @@ -44,6 +44,9 @@ 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/Guide.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/Guide.cs index 4e00d75..53613ef 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/Guide.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/Guide.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; using TravelAgencyDataModels.Models; @@ -18,6 +19,12 @@ namespace TravelAgencyDatabaseImplement.Models [Required] public string PhoneNumber { get; set; } = string.Empty; + [ForeignKey("GuideId")] + public virtual List Trips { get; set; } = new(); + + [ForeignKey("GuideId")] + public virtual List ExcursionGroups { get; set; } = new(); + public static Guide? Create(GuideBindingModel? model) { if (model == null) diff --git a/TravelAgency/TravelAgencyDatabaseImplement/Models/User.cs b/TravelAgency/TravelAgencyDatabaseImplement/Models/User.cs index 2932ff0..68fc1a8 100644 --- a/TravelAgency/TravelAgencyDatabaseImplement/Models/User.cs +++ b/TravelAgency/TravelAgencyDatabaseImplement/Models/User.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; using TravelAgencyContracts.BindingModels; using TravelAgencyContracts.ViewModels; using TravelAgencyDataModels.Models; @@ -21,6 +22,15 @@ namespace TravelAgencyDatabaseImplement.Models [Required] public string Password { get; set; } = string.Empty; + [ForeignKey("UserId")] + public virtual List Excursions { get; set; } = new(); + + [ForeignKey("UserId")] + public virtual List ExcursionGroups { get; set; } = new(); + + [ForeignKey("UserId")] + public virtual List Tours { get; set; } = new(); + public static User? Create(UserBindingModel? model) { if (model == null)