Basic implementation of jobs in the character profile.
This commit is contained in:
142
Content.Server.Database/Migrations/20200118195640_jobs.Designer.cs
generated
Normal file
142
Content.Server.Database/Migrations/20200118195640_jobs.Designer.cs
generated
Normal file
@@ -0,0 +1,142 @@
|
||||
// <auto-generated />
|
||||
using Content.Server.Database;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
namespace Content.Server.Database.Migrations
|
||||
{
|
||||
[DbContext(typeof(PreferencesDbContext))]
|
||||
[Migration("20200118195640_jobs")]
|
||||
partial class jobs
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "3.1.0");
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.HumanoidProfile", b =>
|
||||
{
|
||||
b.Property<int>("HumanoidProfileId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("Age")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("CharacterName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("EyeColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FacialHairColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("FacialHairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("HairColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("HairName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("PrefsId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Sex")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<string>("SkinColor")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Slot")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("SlotName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("HumanoidProfileId");
|
||||
|
||||
b.HasIndex("PrefsId");
|
||||
|
||||
b.ToTable("HumanoidProfile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Job", b =>
|
||||
{
|
||||
b.Property<int>("JobId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("JobName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProfileHumanoidProfileId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("JobId");
|
||||
|
||||
b.HasIndex("ProfileHumanoidProfileId");
|
||||
|
||||
b.ToTable("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Prefs", b =>
|
||||
{
|
||||
b.Property<int>("PrefsId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("SelectedCharacterSlot")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("Username")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.HasKey("PrefsId");
|
||||
|
||||
b.HasIndex("Username")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Preferences");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.HumanoidProfile", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.Prefs", "Prefs")
|
||||
.WithMany("HumanoidProfiles")
|
||||
.HasForeignKey("PrefsId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Job", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.HumanoidProfile", "Profile")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("ProfileHumanoidProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
||||
42
Content.Server.Database/Migrations/20200118195640_jobs.cs
Normal file
42
Content.Server.Database/Migrations/20200118195640_jobs.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
namespace Content.Server.Database.Migrations
|
||||
{
|
||||
public partial class jobs : Migration
|
||||
{
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Job",
|
||||
columns: table => new
|
||||
{
|
||||
JobId = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
ProfileHumanoidProfileId = table.Column<int>(nullable: false),
|
||||
JobName = table.Column<string>(nullable: false),
|
||||
Priority = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Job", x => x.JobId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Job_HumanoidProfile_ProfileHumanoidProfileId",
|
||||
column: x => x.ProfileHumanoidProfileId,
|
||||
principalTable: "HumanoidProfile",
|
||||
principalColumn: "HumanoidProfileId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Job_ProfileHumanoidProfileId",
|
||||
table: "Job",
|
||||
column: "ProfileHumanoidProfileId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Job");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,29 @@ namespace Content.Server.Database.Migrations
|
||||
b.ToTable("HumanoidProfile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Job", b =>
|
||||
{
|
||||
b.Property<int>("JobId")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<string>("JobName")
|
||||
.IsRequired()
|
||||
.HasColumnType("TEXT");
|
||||
|
||||
b.Property<int>("Priority")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.Property<int>("ProfileHumanoidProfileId")
|
||||
.HasColumnType("INTEGER");
|
||||
|
||||
b.HasKey("JobId");
|
||||
|
||||
b.HasIndex("ProfileHumanoidProfileId");
|
||||
|
||||
b.ToTable("Job");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Prefs", b =>
|
||||
{
|
||||
b.Property<int>("PrefsId")
|
||||
@@ -102,6 +125,15 @@ namespace Content.Server.Database.Migrations
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Content.Server.Database.Job", b =>
|
||||
{
|
||||
b.HasOne("Content.Server.Database.HumanoidProfile", "Profile")
|
||||
.WithMany("Jobs")
|
||||
.HasForeignKey("ProfileHumanoidProfileId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +47,27 @@ namespace Content.Server.Database
|
||||
public string FacialHairColor { get; set; } = null!;
|
||||
public string EyeColor { get; set; } = null!;
|
||||
public string SkinColor { get; set; } = null!;
|
||||
public List<Job> Jobs { get; } = new List<Job>();
|
||||
|
||||
public int PrefsId { get; set; }
|
||||
public Prefs Prefs { get; set; } = null!;
|
||||
}
|
||||
|
||||
public class Job
|
||||
{
|
||||
public int JobId { get; set; }
|
||||
public HumanoidProfile Profile { get; set; } = null!;
|
||||
|
||||
public string JobName { get; set; } = null!;
|
||||
public DbJobPriority Priority { get; set; }
|
||||
}
|
||||
|
||||
public enum DbJobPriority
|
||||
{
|
||||
// These enum values HAVE to match the ones in JobPriority in Shared.
|
||||
Never = 0,
|
||||
Low = 1,
|
||||
Medium = 2,
|
||||
High = 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Content.Server.Database
|
||||
return _prefsCtx
|
||||
.Preferences
|
||||
.Include(p => p.HumanoidProfiles)
|
||||
.ThenInclude(h => h.Jobs)
|
||||
.SingleOrDefault(p => p.Username == username);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user