This commit is contained in:
hydrant
2019-05-13 18:20:27 +02:00
parent 27f6279429
commit 2e1ebc9e4e
6 changed files with 1295 additions and 4 deletions

View File

@@ -62,6 +62,8 @@ namespace ReallifeGamemode.Server.Entities
public GroupRank GroupRank { get; set; }
public Job Job { get; set; }
public FactionRank GetFactionRank()
{
using (var dbContext = new DatabaseContext())

View File

@@ -28,9 +28,10 @@ namespace ReallifeGamemode.Server.Extensions
if (!client.IsLoggedIn()) return null;
return context
.Users
//.Include(u => u.Faction)
//.Include(u => u.FactionRank)
//.Include(u => u.Group)
.Include(u => u.Faction)
.Include(u => u.FactionRank)
.Include(u => u.Group)
.Include(u => u.Job)
.Where(u => u.Name == client.Name)
.FirstOrDefault();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
namespace ReallifeGamemode.Migrations
{
public partial class Jobs : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "JobId",
table: "Users",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "JobId",
table: "ServerVehicles",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ShopId",
table: "ServerVehicles",
nullable: true);
migrationBuilder.CreateTable(
name: "Jobs",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Jobs", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Users_JobId",
table: "Users",
column: "JobId");
migrationBuilder.CreateIndex(
name: "IX_ServerVehicles_JobId",
table: "ServerVehicles",
column: "JobId");
migrationBuilder.AddForeignKey(
name: "FK_ServerVehicles_Jobs_JobId",
table: "ServerVehicles",
column: "JobId",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Users_Jobs_JobId",
table: "Users",
column: "JobId",
principalTable: "Jobs",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_ServerVehicles_Jobs_JobId",
table: "ServerVehicles");
migrationBuilder.DropForeignKey(
name: "FK_Users_Jobs_JobId",
table: "Users");
migrationBuilder.DropTable(
name: "Jobs");
migrationBuilder.DropIndex(
name: "IX_Users_JobId",
table: "Users");
migrationBuilder.DropIndex(
name: "IX_ServerVehicles_JobId",
table: "ServerVehicles");
migrationBuilder.DropColumn(
name: "JobId",
table: "Users");
migrationBuilder.DropColumn(
name: "JobId",
table: "ServerVehicles");
migrationBuilder.DropColumn(
name: "ShopId",
table: "ServerVehicles");
}
}
}

View File

@@ -14,7 +14,7 @@ namespace ReallifeGamemode.Migrations
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "2.2.4-servicing-10062")
.HasAnnotation("ProductVersion", "2.2.0-rtm-35687")
.HasAnnotation("Relational:MaxIdentifierLength", 64);
modelBuilder.Entity("ReallifeGamemode.Server.Entities.ATM", b =>
@@ -420,6 +420,18 @@ namespace ReallifeGamemode.Migrations
b.ToTable("Interiors");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Job", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Name");
b.HasKey("Id");
b.ToTable("Jobs");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Logs.BankAccountTransactionHistory", b =>
{
b.Property<int>("Id")
@@ -778,6 +790,8 @@ namespace ReallifeGamemode.Migrations
b.Property<int>("Handmoney");
b.Property<int?>("JobId");
b.Property<int>("LogUserId");
b.Property<string>("Name")
@@ -813,6 +827,8 @@ namespace ReallifeGamemode.Migrations
b.HasIndex("GroupId");
b.HasIndex("JobId");
b.ToTable("Users");
});
@@ -915,6 +931,17 @@ namespace ReallifeGamemode.Migrations
b.HasDiscriminator().HasValue("GroupVehicle");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.JobVehicle", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
b.Property<int?>("JobId");
b.HasIndex("JobId");
b.HasDiscriminator().HasValue("JobVehicle");
});
modelBuilder.Entity("ReallifeGamemode.Server.Entities.Saves.SavedVehicle", b =>
{
b.HasBaseType("ReallifeGamemode.Server.Entities.ServerVehicle");
@@ -930,6 +957,8 @@ namespace ReallifeGamemode.Migrations
b.Property<int>("Price");
b.Property<int?>("ShopId");
b.ToTable("ShopVehicles");
b.HasDiscriminator().HasValue("ShopVehicle");
@@ -1050,6 +1079,10 @@ namespace ReallifeGamemode.Migrations
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.UserBankAccount", b =>
@@ -1090,6 +1123,13 @@ namespace ReallifeGamemode.Migrations
.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")

View File

@@ -99,5 +99,9 @@ namespace ReallifeGamemode.Server.Models
public DbSet<Entities.Group> Groups { get; set; }
public DbSet<Entities.GroupBankAccount> GroupBankAccounts { get; set; }
public DbSet<Entities.GroupVehicle> GroupVehicles { get; set; }
// Jobs
public DbSet<Entities.Job> Jobs { get; set; }
public DbSet<Entities.JobVehicle> JobVehicles { get; set; }
}
}