Revert "summarize bank accounts"

This reverts commit a21e7f887a.
This commit is contained in:
hydrant
2019-05-13 20:34:46 +02:00
parent a21e7f887a
commit 4500aa5275
10 changed files with 135 additions and 1499 deletions

View File

@@ -1,26 +0,0 @@
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; }
}
}

View File

@@ -9,12 +9,15 @@ using System.Text;
namespace ReallifeGamemode.Server.Entities namespace ReallifeGamemode.Server.Entities
{ {
public class BusinessBankAccount : BankAccount, IBankAccount public class BusinessBankAccount : IBankAccount
{ {
[NotMapped] [NotMapped]
private int _balance; private int _balance;
public override int Balance [Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int Balance
{ {
get => _balance; get => _balance;
set set

View File

@@ -13,11 +13,19 @@ using System.Text;
*/ */
namespace ReallifeGamemode.Server.Entities namespace ReallifeGamemode.Server.Entities
{ {
public class FactionBankAccount : BankAccount, IBankAccount public class FactionBankAccount : IBankAccount
{ {
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("Faction")] [ForeignKey("Faction")]
public int FactionId { get; set; } public int FactionId { get; set; }
public Faction Faction { 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; }
} }
} }

View File

@@ -7,8 +7,14 @@ using System.Text;
namespace ReallifeGamemode.Server.Entities namespace ReallifeGamemode.Server.Entities
{ {
public class GroupBankAccount : BankAccount, IBankAccount public class GroupBankAccount : IBankAccount
{ {
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public Group Group { get; set; } public Group Group { get; set; }
public int Balance { get; set; }
} }
} }

View File

@@ -13,17 +13,22 @@ using System.Linq;
namespace ReallifeGamemode.Server.Entities namespace ReallifeGamemode.Server.Entities
{ {
public class UserBankAccount : BankAccount, IBankAccount public class UserBankAccount : IBankAccount
{ {
[NotMapped] [NotMapped]
private int _balance; private int _balance;
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
[ForeignKey("User")] [ForeignKey("User")]
public int UserId { get; set; } public int UserId { get; set; }
public User User { get; set; } public User User { get; set; }
[StringLength(12)]
public override int Balance public string Bic { get; set; }
[StringLength(32)]
public string Iban { get; set; }
public int Balance
{ {
get => _balance; get => _balance;
set set
@@ -35,5 +40,6 @@ namespace ReallifeGamemode.Server.Entities
} }
} }
} }
public bool Active { get; set; }
} }
} }

View File

@@ -17,6 +17,11 @@ namespace ReallifeGamemode.Migrations
table: "ServerVehicles", table: "ServerVehicles",
nullable: true); nullable: true);
migrationBuilder.AddColumn<int>(
name: "ShopId",
table: "ServerVehicles",
nullable: true);
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Jobs", name: "Jobs",
columns: table => new columns: table => new
@@ -85,6 +90,10 @@ namespace ReallifeGamemode.Migrations
migrationBuilder.DropColumn( migrationBuilder.DropColumn(
name: "JobId", name: "JobId",
table: "ServerVehicles"); table: "ServerVehicles");
migrationBuilder.DropColumn(
name: "ShopId",
table: "ServerVehicles");
} }
} }
} }

View File

@@ -1,248 +0,0 @@
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<int>(
name: "UserId",
table: "BankAccounts",
nullable: true,
oldClrType: typeof(int));
migrationBuilder.AddColumn<string>(
name: "Discriminator",
table: "BankAccounts",
nullable: false,
defaultValue: "");
migrationBuilder.AddColumn<int>(
name: "BusinessId",
table: "BankAccounts",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "FactionId",
table: "BankAccounts",
nullable: true);
migrationBuilder.AddColumn<int>(
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<int>(
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<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Balance = table.Column<int>(nullable: false),
BusinessId = table.Column<int>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BusinessBankAccounts", x => x.Id);
});
migrationBuilder.CreateTable(
name: "FactionBankAccounts",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
Balance = table.Column<int>(nullable: false),
Bic = table.Column<string>(maxLength: 12, nullable: true),
FactionId = table.Column<int>(nullable: false),
Iban = table.Column<string>(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<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Balance = table.Column<int>(nullable: false),
GroupId = table.Column<int>(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);
}
}
}

View File

@@ -61,29 +61,21 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Bans"); b.ToTable("Bans");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.BankAccount", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
.ValueGeneratedOnAdd(); .ValueGeneratedOnAdd();
b.Property<bool>("Active");
b.Property<int>("Balance"); b.Property<int>("Balance");
b.Property<string>("Bic") b.Property<int>("BusinessId");
.HasMaxLength(12);
b.Property<string>("Discriminator")
.IsRequired();
b.Property<string>("Iban")
.HasMaxLength(32);
b.HasKey("Id"); b.HasKey("Id");
b.ToTable("BankAccounts"); b.HasIndex("BusinessId")
.IsUnique();
b.HasDiscriminator<string>("Discriminator").HasValue("BankAccount"); b.ToTable("BusinessBankAccounts");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.Character", b =>
@@ -319,6 +311,30 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Factions"); b.ToTable("Factions");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Active");
b.Property<int>("Balance");
b.Property<string>("Bic")
.HasMaxLength(12);
b.Property<int>("FactionId");
b.Property<string>("Iban")
.HasMaxLength(32);
b.HasKey("Id");
b.HasIndex("FactionId");
b.ToTable("FactionBankAccounts");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -370,6 +386,22 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Groups"); b.ToTable("Groups");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Balance");
b.Property<int?>("GroupId");
b.HasKey("Id");
b.HasIndex("GroupId");
b.ToTable("GroupBankAccounts");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.Interior", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -800,6 +832,30 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Users"); b.ToTable("Users");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<bool>("Active");
b.Property<int>("Balance");
b.Property<string>("Bic")
.HasMaxLength(12);
b.Property<string>("Iban")
.HasMaxLength(32);
b.Property<int>("UserId");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("UserBankAccounts");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@@ -851,51 +907,6 @@ namespace ReallifeGamemode.Migrations
b.ToTable("WhitelistEntries"); b.ToTable("WhitelistEntries");
}); });
modelBuilder.Entity("ReallifeGamemode.Server.Entities.BusinessBankAccount", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount");
b.Property<int>("BusinessId");
b.HasIndex("BusinessId")
.IsUnique();
b.HasDiscriminator().HasValue("BusinessBankAccount");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionBankAccount", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount");
b.Property<int>("FactionId");
b.HasIndex("FactionId");
b.HasDiscriminator().HasValue("FactionBankAccount");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.GroupBankAccount", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount");
b.Property<int?>("GroupId");
b.HasIndex("GroupId");
b.HasDiscriminator().HasValue("GroupBankAccount");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserBankAccount", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.BankAccount");
b.Property<int>("UserId");
b.HasIndex("UserId");
b.HasDiscriminator().HasValue("UserBankAccount");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b => modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b =>
{ {
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle"); b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
@@ -946,6 +957,8 @@ namespace ReallifeGamemode.Migrations
b.Property<int>("Price"); b.Property<int>("Price");
b.Property<int?>("ShopId");
b.ToTable("ShopVehicles"); b.ToTable("ShopVehicles");
b.HasDiscriminator().HasValue("ShopVehicle"); b.HasDiscriminator().HasValue("ShopVehicle");
@@ -1003,6 +1016,14 @@ namespace ReallifeGamemode.Migrations
.OnDelete(DeleteBehavior.Cascade); .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 => modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionRank", b =>
{ {
b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction")
@@ -1011,6 +1032,13 @@ namespace ReallifeGamemode.Migrations
.OnDelete(DeleteBehavior.Cascade); .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 => modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.Death", b =>
{ {
b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer") b.HasOne("ReallifeGamemode.Server.Entities.User", "Killer")
@@ -1057,6 +1085,14 @@ namespace ReallifeGamemode.Migrations
.HasForeignKey("JobId"); .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 => modelBuilder.Entity("ReallifeGamemode.Server.Entities.UserItem", b =>
{ {
b.HasOne("ReallifeGamemode.Server.Entities.User", "User") b.HasOne("ReallifeGamemode.Server.Entities.User", "User")
@@ -1073,29 +1109,6 @@ namespace ReallifeGamemode.Migrations
.OnDelete(DeleteBehavior.Cascade); .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 => modelBuilder.Entity("ReallifeGamemode.Server.Entities.FactionVehicle", b =>
{ {
b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction") b.HasOne("ReallifeGamemode.Server.Entities.Faction", "Faction")

View File

@@ -36,9 +36,6 @@ namespace ReallifeGamemode.Server.Models
.HasIndex(vM => new { vM.ServerVehicleId, vM.Slot }).IsUnique(); .HasIndex(vM => new { vM.ServerVehicleId, vM.Slot }).IsUnique();
} }
// Bank Accounts
public DbSet<Entities.BankAccount> BankAccounts { get; set; }
//User //User
public DbSet<Entities.Ban> Bans { get; set; } public DbSet<Entities.Ban> Bans { get; set; }
public DbSet<Entities.Character> Characters { get; set; } public DbSet<Entities.Character> Characters { get; set; }