фикс связей
This commit is contained in:
parent
b4395026c7
commit
cc9d05ccf5
@ -12,7 +12,7 @@ using TravelAgencyDatabaseImplement;
|
||||
namespace TravelAgencyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(TravelAgencyDatabase))]
|
||||
[Migration("20240429172546_InitialCreate")]
|
||||
[Migration("20240429175309_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
@ -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
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -44,6 +44,9 @@ namespace TravelAgencyDatabaseImplement.Models
|
||||
[ForeignKey("ExcursionId")]
|
||||
public virtual List<ExcursionTour> Tours { get; set; } = new();
|
||||
|
||||
[ForeignKey("ExcursionId")]
|
||||
public virtual List<Place> Places { get; set; } = new();
|
||||
|
||||
public static Excursion? Create(TravelAgencyDatabase context, ExcursionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -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<Trip> Trips { get; set; } = new();
|
||||
|
||||
[ForeignKey("GuideId")]
|
||||
public virtual List<ExcursionGroup> ExcursionGroups { get; set; } = new();
|
||||
|
||||
public static Guide? Create(GuideBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
@ -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<Excursion> Excursions { get; set; } = new();
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<ExcursionGroup> ExcursionGroups { get; set; } = new();
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public virtual List<Tour> Tours { get; set; } = new();
|
||||
|
||||
public static User? Create(UserBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
|
Loading…
Reference in New Issue
Block a user