miete alle 7 tage nachricht angepasst

improvements in db und haussystem
This commit is contained in:
hydrant
2020-03-29 18:51:18 +02:00
parent 0dc1235909
commit 5a3dc6de75
3 changed files with 59 additions and 39 deletions

View File

@@ -1,9 +1,8 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using GTANetworkAPI;
using ReallifeGamemode.Server.Core.API;
using ReallifeGamemode.Server.Core.RageMP;
namespace ReallifeGamemode.Database.Entities
{
@@ -33,5 +32,7 @@ namespace ReallifeGamemode.Database.Entities
[ForeignKey("Owner")]
public int? OwnerId { get; set; }
public User Owner { get; set; }
public ICollection<HouseRental> Rentals { get; set; }
}
}

View File

@@ -51,6 +51,25 @@ namespace ReallifeGamemode.Database.Models
modelBuilder.Entity<Entities.VehicleMod>()
.HasIndex(vM => new { vM.ServerVehicleId, vM.Slot }).IsUnique();
modelBuilder.Entity<Entities.HouseRental>()
.HasIndex(hR => new
{
hR.HouseId,
hR.UserId
}).IsUnique();
modelBuilder.Entity<Entities.House>()
.HasMany(h => h.Rentals)
.WithOne(hR => hR.House);
modelBuilder.Entity<Entities.User>()
.HasOne(u => u.House)
.WithOne(h => h.Owner);
modelBuilder.Entity<Entities.House>()
.HasOne(h => h.Owner)
.WithOne(u => u.House);
}
//User