diff --git a/ReallifeGamemode.Server/Entities/BankAccount.cs b/ReallifeGamemode.Server/Entities/BankAccount.cs new file mode 100644 index 00000000..345f06f9 --- /dev/null +++ b/ReallifeGamemode.Server/Entities/BankAccount.cs @@ -0,0 +1,26 @@ +using ReallifeGamemode.Server.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace ReallifeGamemode.Server.Entities +{ + public abstract class BankAccount + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + [StringLength(12)] + public string Bic { get; set; } + + [StringLength(32)] + public string Iban { get; set; } + + public virtual int Balance { get; set; } + + public bool Active { get; set; } + } +} diff --git a/ReallifeGamemode.Server/Entities/BusinessBankAccount.cs b/ReallifeGamemode.Server/Entities/BusinessBankAccount.cs index d25e1fa9..93dd6512 100644 --- a/ReallifeGamemode.Server/Entities/BusinessBankAccount.cs +++ b/ReallifeGamemode.Server/Entities/BusinessBankAccount.cs @@ -9,15 +9,12 @@ using System.Text; namespace ReallifeGamemode.Server.Entities { - public class BusinessBankAccount : IBankAccount + public class BusinessBankAccount : BankAccount, IBankAccount { [NotMapped] private int _balance; - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - public int Balance + public override int Balance { get => _balance; set diff --git a/ReallifeGamemode.Server/Entities/FactionBankAccount.cs b/ReallifeGamemode.Server/Entities/FactionBankAccount.cs index 1502f972..90428c84 100644 --- a/ReallifeGamemode.Server/Entities/FactionBankAccount.cs +++ b/ReallifeGamemode.Server/Entities/FactionBankAccount.cs @@ -13,19 +13,11 @@ using System.Text; */ namespace ReallifeGamemode.Server.Entities { - public class FactionBankAccount : IBankAccount + public class FactionBankAccount : BankAccount, IBankAccount { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } [ForeignKey("Faction")] public int FactionId { get; set; } + public Faction Faction { get; set; } - [StringLength(12)] - public string Bic { get; set; } - [StringLength(32)] - public string Iban { get; set; } - public int Balance { get; set; } - public bool Active { get; set; } } } diff --git a/ReallifeGamemode.Server/Entities/GroupBankAccount.cs b/ReallifeGamemode.Server/Entities/GroupBankAccount.cs index 62d1e1ae..f1b3be19 100644 --- a/ReallifeGamemode.Server/Entities/GroupBankAccount.cs +++ b/ReallifeGamemode.Server/Entities/GroupBankAccount.cs @@ -7,14 +7,8 @@ using System.Text; namespace ReallifeGamemode.Server.Entities { - public class GroupBankAccount : IBankAccount + public class GroupBankAccount : BankAccount, IBankAccount { - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } - public Group Group { get; set; } - - public int Balance { get; set; } } } diff --git a/ReallifeGamemode.Server/Entities/UserBankAccount.cs b/ReallifeGamemode.Server/Entities/UserBankAccount.cs index 72073afa..3a913c24 100644 --- a/ReallifeGamemode.Server/Entities/UserBankAccount.cs +++ b/ReallifeGamemode.Server/Entities/UserBankAccount.cs @@ -13,22 +13,17 @@ using System.Linq; namespace ReallifeGamemode.Server.Entities { - public class UserBankAccount : IBankAccount + public class UserBankAccount : BankAccount, IBankAccount { [NotMapped] private int _balance; - [Key] - [DatabaseGenerated(DatabaseGeneratedOption.Identity)] - public int Id { get; set; } [ForeignKey("User")] public int UserId { get; set; } + public User User { get; set; } - [StringLength(12)] - public string Bic { get; set; } - [StringLength(32)] - public string Iban { get; set; } - public int Balance + + public override int Balance { get => _balance; set @@ -40,6 +35,5 @@ namespace ReallifeGamemode.Server.Entities } } } - public bool Active { get; set; } } } \ No newline at end of file diff --git a/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs b/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs index 0675ddc3..8ad5a9bb 100644 --- a/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs +++ b/ReallifeGamemode.Server/Migrations/20190513161249_Jobs.cs @@ -17,11 +17,6 @@ namespace ReallifeGamemode.Migrations table: "ServerVehicles", nullable: true); - migrationBuilder.AddColumn( - name: "ShopId", - table: "ServerVehicles", - nullable: true); - migrationBuilder.CreateTable( name: "Jobs", columns: table => new @@ -90,10 +85,6 @@ namespace ReallifeGamemode.Migrations migrationBuilder.DropColumn( name: "JobId", table: "ServerVehicles"); - - migrationBuilder.DropColumn( - name: "ShopId", - table: "ServerVehicles"); } } } diff --git a/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.Designer.cs b/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.Designer.cs new file mode 100644 index 00000000..3cdfce59 --- /dev/null +++ b/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.Designer.cs @@ -0,0 +1,1132 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using ReallifeGamemode.Server.Models; + +namespace ReallifeGamemode.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20190513174429_BankAccountSummary")] + partial class BankAccountSummary + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "2.2.0-rtm-35687") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ATM", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Faulty"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("ATMs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Ban", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Applied"); + + b.Property("BannedBy"); + + b.Property("Reason"); + + b.Property("UntilDateTime"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Bans"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.BankAccount", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Balance"); + + b.Property("Bic") + .HasMaxLength(12); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("Iban") + .HasMaxLength(32); + + b.HasKey("Id"); + + b.ToTable("BankAccounts"); + + b.HasDiscriminator("Discriminator").HasValue("BankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Ageing"); + + b.Property("AgeingOpacity"); + + b.Property("BeardColor"); + + b.Property("Blemishes"); + + b.Property("BlemishesOpacity"); + + b.Property("Blush"); + + b.Property("BlushColor"); + + b.Property("BlushOpacity"); + + b.Property("BrowDepth"); + + b.Property("BrowHeight"); + + b.Property("CheekDepth"); + + b.Property("CheekboneHeight"); + + b.Property("CheekboneWidth"); + + b.Property("ChestHair"); + + b.Property("ChestHairColor"); + + b.Property("ChestHairOpacity"); + + b.Property("ChinDepth"); + + b.Property("ChinHeight"); + + b.Property("ChinIndent"); + + b.Property("ChinWidth"); + + b.Property("Complexion"); + + b.Property("ComplexionOpacity"); + + b.Property("EyeColor"); + + b.Property("EyeSize"); + + b.Property("EyebrowColor"); + + b.Property("Eyebrows"); + + b.Property("EyebrowsOpacity"); + + b.Property("FacialHair"); + + b.Property("FacialHairOpacity"); + + b.Property("Father"); + + b.Property("Freckles"); + + b.Property("FrecklesOpacity"); + + b.Property("Gender"); + + b.Property("Hair"); + + b.Property("HairColor"); + + b.Property("HairHighlightColor"); + + b.Property("JawShape"); + + b.Property("JawWidth"); + + b.Property("LipThickness"); + + b.Property("Lipstick"); + + b.Property("LipstickColor"); + + b.Property("LipstickOpacity"); + + b.Property("Makeup"); + + b.Property("MakeupOpacity"); + + b.Property("Mother"); + + b.Property("NeckWidth"); + + b.Property("NoseBottomHeight"); + + b.Property("NoseBridgeDepth"); + + b.Property("NoseBroken"); + + b.Property("NoseTipHeight"); + + b.Property("NoseTipLength"); + + b.Property("NoseWidth"); + + b.Property("Similarity"); + + b.Property("SkinSimilarity"); + + b.Property("SunDamage"); + + b.Property("SunDamageOpacity"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("Characters"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.CharacterCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("Duty"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("CharacterClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ClothCombination", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Gender"); + + b.Property("Top"); + + b.Property("Torso"); + + b.Property("Undershirt"); + + b.HasKey("Id"); + + b.ToTable("ClothCombinations"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Door", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Category"); + + b.Property("FactionId"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("Name"); + + b.Property("Radius"); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("Doors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.DutyCloth", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ClothId"); + + b.Property("FactionId"); + + b.Property("Gender"); + + b.Property("SlotId"); + + b.Property("SlotType"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("DutyClothes"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Faction", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("StateOwned"); + + b.HasKey("Id"); + + b.ToTable("Factions"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("FactionId"); + + b.Property("Order"); + + b.Property("RankName"); + + b.HasKey("Id"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionRanks"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GotoPoint", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Description") + .HasMaxLength(32); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("GotoPoints"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Group", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("EnterPositionStr") + .HasColumnName("EnterPosition"); + + b.Property("ExitPositionStr") + .HasColumnName("ExitPosition"); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Interiors"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Name"); + + b.HasKey("Id"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.BankAccountTransactionHistory", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Fee"); + + b.Property("MoneySent"); + + b.Property("NewReceiverBalance"); + + b.Property("NewSenderBalance"); + + b.Property("Origin") + .HasMaxLength(32); + + b.Property("Receiver") + .HasMaxLength(32); + + b.Property("ReceiverBalance"); + + b.Property("Sender") + .HasMaxLength(32); + + b.Property("SenderBalance"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.HasKey("Id"); + + b.ToTable("BankAccountTransactionLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("CauseOfDeath") + .HasMaxLength(64); + + b.Property("KillerHeading"); + + b.Property("KillerId"); + + b.Property("KillerPositionX"); + + b.Property("KillerPositionY"); + + b.Property("KillerPositionZ"); + + b.Property("Timestamp") + .ValueGeneratedOnAdd(); + + b.Property("VictimHeading"); + + b.Property("VictimId"); + + b.Property("VictimPositionX"); + + b.Property("VictimPositionY"); + + b.Property("VictimPositionZ"); + + b.HasKey("Id"); + + b.HasIndex("KillerId"); + + b.HasIndex("VictimId"); + + b.ToTable("DeathLogs"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.News", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Caption"); + + b.Property("Content"); + + b.Property("Timestamp"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("News"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedBlip", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Alpha"); + + b.Property("Color"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Name"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Rotation"); + + b.Property("Scale"); + + b.Property("ShortRange"); + + b.Property("Sprite"); + + b.HasKey("Id"); + + b.ToTable("Blips"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedMarker", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DirectionX"); + + b.Property("DirectionY"); + + b.Property("DirectionZ"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Scale"); + + b.Property("Type"); + + b.Property("Visible"); + + b.HasKey("Id"); + + b.ToTable("Markers"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedPed", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("HashModel"); + + b.Property("Heading"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.HasKey("Id"); + + b.ToTable("Peds"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedPickup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("Dimension"); + + b.Property("PositionX") + .HasMaxLength(128); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RespawnTime"); + + b.Property("RotationX"); + + b.Property("RotationY"); + + b.Property("RotationZ"); + + b.Property("Vehicle"); + + b.HasKey("Id"); + + b.ToTable("Pickups"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedTextLabel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active"); + + b.Property("ColorA"); + + b.Property("ColorB"); + + b.Property("ColorG"); + + b.Property("ColorR"); + + b.Property("Dimension"); + + b.Property("DrawDistance"); + + b.Property("Font"); + + b.Property("LOS"); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("Text") + .IsRequired(); + + b.HasKey("Id"); + + b.ToTable("TextLabels"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ServerVehicle", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Active") + .ValueGeneratedOnAdd() + .HasDefaultValue(true); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("DistanceDriven"); + + b.Property("Heading"); + + b.Property("Locked"); + + b.Property("Model"); + + b.Property("NumberPlate") + .HasMaxLength(8); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("PrimaryColor"); + + b.Property("SecondaryColor"); + + b.Property("TankAmount"); + + b.HasKey("Id"); + + b.ToTable("ServerVehicles"); + + b.HasDiscriminator("Discriminator").HasValue("ServerVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.TuningGarage", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("X"); + + b.Property("Y"); + + b.Property("Z"); + + b.HasKey("Id"); + + b.ToTable("TuningGarages"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("AdminLevel"); + + b.Property("BanId"); + + b.Property("BusinessId"); + + b.Property("CharacterId"); + + b.Property("Dead"); + + b.Property("Email") + .HasMaxLength(64); + + b.Property("FactionId"); + + b.Property("FactionLeader"); + + b.Property("FactionRankId"); + + b.Property("GroupId"); + + b.Property("GroupRank"); + + b.Property("Handmoney"); + + b.Property("JobId"); + + b.Property("LogUserId"); + + b.Property("Name") + .HasMaxLength(32); + + b.Property("Password") + .HasMaxLength(64); + + b.Property("PositionX"); + + b.Property("PositionY"); + + b.Property("PositionZ"); + + b.Property("RegistrationDate") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName") + .HasMaxLength(32); + + b.HasKey("Id"); + + b.HasIndex("BanId"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.HasIndex("CharacterId"); + + b.HasIndex("FactionId"); + + b.HasIndex("FactionRankId"); + + b.HasIndex("GroupId"); + + b.HasIndex("JobId"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("Amount"); + + b.Property("ItemId"); + + b.Property("Slot"); + + b.Property("UserId"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("UserItems"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.VehicleMod", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("ModId"); + + b.Property("ServerVehicleId"); + + b.Property("Slot"); + + b.HasKey("Id"); + + b.HasIndex("ServerVehicleId", "Slot") + .IsUnique(); + + b.ToTable("VehicleMods"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Whitelist", b => + { + b.Property("Id") + .ValueGeneratedOnAdd(); + + b.Property("SocialClubName"); + + b.HasKey("Id"); + + b.ToTable("WhitelistEntries"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("BusinessId"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.HasDiscriminator().HasValue("BusinessBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("FactionId"); + + b.HasIndex("FactionId"); + + b.HasDiscriminator().HasValue("FactionBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("GroupId"); + + b.HasIndex("GroupId"); + + b.HasDiscriminator().HasValue("GroupBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("UserId"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("UserBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("FactionId"); + + b.HasIndex("FactionId"); + + b.ToTable("FactionVehicles"); + + b.HasDiscriminator().HasValue("FactionVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("GroupId"); + + b.HasIndex("GroupId"); + + b.HasDiscriminator().HasValue("GroupVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("JobId"); + + b.HasIndex("JobId"); + + b.HasDiscriminator().HasValue("JobVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.HasDiscriminator().HasValue("SavedVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.ShopVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("BusinessId"); + + b.Property("Price"); + + b.ToTable("ShopVehicles"); + + b.HasDiscriminator().HasValue("ShopVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); + + b.Property("UserId"); + + b.HasIndex("UserId"); + + b.ToTable("UserVehicles"); + + b.HasDiscriminator().HasValue("UserVehicle"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Ban", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.CharacterCloth", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Door", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.DutyCloth", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer") + .WithMany() + .HasForeignKey("KillerId"); + + b.HasOne("ReallifeGamemode.Server.Entities.User", "Victim") + .WithMany() + .HasForeignKey("VictimId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.News", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.User", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Ban", "Ban") + .WithMany() + .HasForeignKey("BanId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Character", "Character") + .WithMany() + .HasForeignKey("CharacterId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + + b.HasOne("ReallifeGamemode.Server.Entities.FactionRank", "FactionRank") + .WithMany() + .HasForeignKey("FactionRankId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + + b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job") + .WithMany() + .HasForeignKey("JobId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.VehicleMod", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.ServerVehicle", "Vehicle") + .WithMany() + .HasForeignKey("ServerVehicleId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Job", "Job") + .WithMany() + .HasForeignKey("JobId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserVehicle", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.cs b/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.cs new file mode 100644 index 00000000..6e38344e --- /dev/null +++ b/ReallifeGamemode.Server/Migrations/20190513174429_BankAccountSummary.cs @@ -0,0 +1,248 @@ +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace ReallifeGamemode.Migrations +{ + public partial class BankAccountSummary : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_UserBankAccounts_Users_UserId", + table: "UserBankAccounts"); + + migrationBuilder.DropTable( + name: "BusinessBankAccounts"); + + migrationBuilder.DropTable( + name: "FactionBankAccounts"); + + migrationBuilder.DropTable( + name: "GroupBankAccounts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_UserBankAccounts", + table: "UserBankAccounts"); + + migrationBuilder.RenameTable( + name: "UserBankAccounts", + newName: "BankAccounts"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "BankAccounts", + nullable: true, + oldClrType: typeof(int)); + + migrationBuilder.AddColumn( + name: "Discriminator", + table: "BankAccounts", + nullable: false, + defaultValue: ""); + + migrationBuilder.AddColumn( + name: "BusinessId", + table: "BankAccounts", + nullable: true); + + migrationBuilder.AddColumn( + name: "FactionId", + table: "BankAccounts", + nullable: true); + + migrationBuilder.AddColumn( + name: "GroupId", + table: "BankAccounts", + nullable: true); + + migrationBuilder.AddPrimaryKey( + name: "PK_BankAccounts", + table: "BankAccounts", + column: "Id"); + + migrationBuilder.CreateIndex( + name: "IX_BankAccounts_BusinessId", + table: "BankAccounts", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_BankAccounts_FactionId", + table: "BankAccounts", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_BankAccounts_GroupId", + table: "BankAccounts", + column: "GroupId"); + + migrationBuilder.AddForeignKey( + name: "FK_BankAccounts_Factions_FactionId", + table: "BankAccounts", + column: "FactionId", + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_BankAccounts_Groups_GroupId", + table: "BankAccounts", + column: "GroupId", + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + + migrationBuilder.AddForeignKey( + name: "FK_BankAccounts_Users_UserId", + table: "BankAccounts", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_BankAccounts_Factions_FactionId", + table: "BankAccounts"); + + migrationBuilder.DropForeignKey( + name: "FK_BankAccounts_Groups_GroupId", + table: "BankAccounts"); + + migrationBuilder.DropForeignKey( + name: "FK_BankAccounts_Users_UserId", + table: "BankAccounts"); + + migrationBuilder.DropPrimaryKey( + name: "PK_BankAccounts", + table: "BankAccounts"); + + migrationBuilder.DropIndex( + name: "IX_BankAccounts_BusinessId", + table: "BankAccounts"); + + migrationBuilder.DropIndex( + name: "IX_BankAccounts_FactionId", + table: "BankAccounts"); + + migrationBuilder.DropIndex( + name: "IX_BankAccounts_GroupId", + table: "BankAccounts"); + + migrationBuilder.DropColumn( + name: "Discriminator", + table: "BankAccounts"); + + migrationBuilder.DropColumn( + name: "BusinessId", + table: "BankAccounts"); + + migrationBuilder.DropColumn( + name: "FactionId", + table: "BankAccounts"); + + migrationBuilder.DropColumn( + name: "GroupId", + table: "BankAccounts"); + + migrationBuilder.RenameTable( + name: "BankAccounts", + newName: "UserBankAccounts"); + + migrationBuilder.AlterColumn( + name: "UserId", + table: "UserBankAccounts", + nullable: false, + oldClrType: typeof(int), + oldNullable: true); + + migrationBuilder.AddPrimaryKey( + name: "PK_UserBankAccounts", + table: "UserBankAccounts", + column: "Id"); + + migrationBuilder.CreateTable( + name: "BusinessBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + BusinessId = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "FactionBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Active = table.Column(nullable: false), + Balance = table.Column(nullable: false), + Bic = table.Column(maxLength: 12, nullable: true), + FactionId = table.Column(nullable: false), + Iban = table.Column(maxLength: 32, nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_FactionBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_FactionBankAccounts_Factions_FactionId", + column: x => x.FactionId, + principalTable: "Factions", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "GroupBankAccounts", + columns: table => new + { + Id = table.Column(nullable: false) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Balance = table.Column(nullable: false), + GroupId = table.Column(nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_GroupBankAccounts", x => x.Id); + table.ForeignKey( + name: "FK_GroupBankAccounts_Groups_GroupId", + column: x => x.GroupId, + principalTable: "Groups", + principalColumn: "Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_BusinessBankAccounts_BusinessId", + table: "BusinessBankAccounts", + column: "BusinessId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_FactionBankAccounts_FactionId", + table: "FactionBankAccounts", + column: "FactionId"); + + migrationBuilder.CreateIndex( + name: "IX_GroupBankAccounts_GroupId", + table: "GroupBankAccounts", + column: "GroupId"); + + migrationBuilder.AddForeignKey( + name: "FK_UserBankAccounts_Users_UserId", + table: "UserBankAccounts", + column: "UserId", + principalTable: "Users", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs b/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs index 5b97fa67..dde8f5b4 100644 --- a/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs +++ b/ReallifeGamemode.Server/Migrations/DatabaseContextModelSnapshot.cs @@ -61,21 +61,29 @@ namespace ReallifeGamemode.Migrations b.ToTable("Bans"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b => + modelBuilder.Entity("ReallifeGamemode.Server.Entities.BankAccount", b => { b.Property("Id") .ValueGeneratedOnAdd(); + b.Property("Active"); + b.Property("Balance"); - b.Property("BusinessId"); + b.Property("Bic") + .HasMaxLength(12); + + b.Property("Discriminator") + .IsRequired(); + + b.Property("Iban") + .HasMaxLength(32); b.HasKey("Id"); - b.HasIndex("BusinessId") - .IsUnique(); + b.ToTable("BankAccounts"); - b.ToTable("BusinessBankAccounts"); + b.HasDiscriminator("Discriminator").HasValue("BankAccount"); }); modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => @@ -311,30 +319,6 @@ namespace ReallifeGamemode.Migrations b.ToTable("Factions"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("Balance"); - - b.Property("Bic") - .HasMaxLength(12); - - b.Property("FactionId"); - - b.Property("Iban") - .HasMaxLength(32); - - b.HasKey("Id"); - - b.HasIndex("FactionId"); - - b.ToTable("FactionBankAccounts"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => { b.Property("Id") @@ -386,22 +370,6 @@ namespace ReallifeGamemode.Migrations b.ToTable("Groups"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Balance"); - - b.Property("GroupId"); - - b.HasKey("Id"); - - b.HasIndex("GroupId"); - - b.ToTable("GroupBankAccounts"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b => { b.Property("Id") @@ -832,30 +800,6 @@ namespace ReallifeGamemode.Migrations b.ToTable("Users"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => - { - b.Property("Id") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("Balance"); - - b.Property("Bic") - .HasMaxLength(12); - - b.Property("Iban") - .HasMaxLength(32); - - b.Property("UserId"); - - b.HasKey("Id"); - - b.HasIndex("UserId"); - - b.ToTable("UserBankAccounts"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => { b.Property("Id") @@ -907,6 +851,51 @@ namespace ReallifeGamemode.Migrations b.ToTable("WhitelistEntries"); }); + modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("BusinessId"); + + b.HasIndex("BusinessId") + .IsUnique(); + + b.HasDiscriminator().HasValue("BusinessBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("FactionId"); + + b.HasIndex("FactionId"); + + b.HasDiscriminator().HasValue("FactionBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("GroupId"); + + b.HasIndex("GroupId"); + + b.HasDiscriminator().HasValue("GroupBankAccount"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount"); + + b.Property("UserId"); + + b.HasIndex("UserId"); + + b.HasDiscriminator().HasValue("UserBankAccount"); + }); + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => { b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); @@ -957,8 +946,6 @@ namespace ReallifeGamemode.Migrations b.Property("Price"); - b.Property("ShopId"); - b.ToTable("ShopVehicles"); b.HasDiscriminator().HasValue("ShopVehicle"); @@ -1016,14 +1003,6 @@ namespace ReallifeGamemode.Migrations .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => - { - b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") - .WithMany() - .HasForeignKey("FactionId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => { b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") @@ -1032,13 +1011,6 @@ namespace ReallifeGamemode.Migrations .OnDelete(DeleteBehavior.Cascade); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => - { - b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") - .WithMany() - .HasForeignKey("GroupId"); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b => { b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer") @@ -1085,14 +1057,6 @@ namespace ReallifeGamemode.Migrations .HasForeignKey("JobId"); }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => - { - b.HasOne("ReallifeGamemode.Server.Entities.User", "User") - .WithMany() - .HasForeignKey("UserId") - .OnDelete(DeleteBehavior.Cascade); - }); - modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => { b.HasOne("ReallifeGamemode.Server.Entities.User", "User") @@ -1109,6 +1073,29 @@ namespace ReallifeGamemode.Migrations .OnDelete(DeleteBehavior.Cascade); }); + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") + .WithMany() + .HasForeignKey("FactionId") + .OnDelete(DeleteBehavior.Cascade); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.Group", "Group") + .WithMany() + .HasForeignKey("GroupId"); + }); + + modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b => + { + b.HasOne("ReallifeGamemode.Server.Entities.User", "User") + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + }); + modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => { b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") diff --git a/ReallifeGamemode.Server/Models/DatabaseContext.cs b/ReallifeGamemode.Server/Models/DatabaseContext.cs index 502279c7..7aa0d13f 100644 --- a/ReallifeGamemode.Server/Models/DatabaseContext.cs +++ b/ReallifeGamemode.Server/Models/DatabaseContext.cs @@ -35,6 +35,9 @@ namespace ReallifeGamemode.Server.Models modelBuilder.Entity() .HasIndex(vM => new { vM.ServerVehicleId, vM.Slot }).IsUnique(); } + + // Bank Accounts + public DbSet BankAccounts { get; set; } //User public DbSet Bans { get; set; }