Added Some based tables and new project
This commit is contained in:
parent
f9cc6273fb
commit
7e15254cc1
@ -0,0 +1,49 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SessionCompanion.Database.Tables;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database
|
||||||
|
{
|
||||||
|
public class ApplicationDbContext : DbContext
|
||||||
|
{
|
||||||
|
public virtual DbSet<Alignment> Alignments { get; set; }
|
||||||
|
public virtual DbSet<Background> Backgrounds { get; set; }
|
||||||
|
public virtual DbSet<Biography> Biographies { get; set; }
|
||||||
|
public virtual DbSet<Character> Characters { get; set; }
|
||||||
|
public virtual DbSet<Class> Classes { get; set; }
|
||||||
|
public virtual DbSet<Race> Races { get; set; }
|
||||||
|
public virtual DbSet<Statistics> Statistics { get; set; }
|
||||||
|
public virtual DbSet<User> Users { get; set; }
|
||||||
|
|
||||||
|
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnModelCreating(ModelBuilder builder)
|
||||||
|
{
|
||||||
|
base.OnModelCreating(builder);
|
||||||
|
builder.Entity<User>().HasData(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
Nickname = "Morwiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 2,
|
||||||
|
Nickname = "Cichoklepiec",
|
||||||
|
Password = "123"
|
||||||
|
},
|
||||||
|
new
|
||||||
|
{
|
||||||
|
Id = 3,
|
||||||
|
Nickname = "Ruletka",
|
||||||
|
Password = "123"
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net5.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Repositories\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Alignment : BaseEntity
|
||||||
|
{
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Background : BaseEntity
|
||||||
|
{
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class BaseEntity
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Biography : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(Character))]
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
public virtual Character Character { get; set; }
|
||||||
|
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Class))]
|
||||||
|
public int ClassId { get; set; }
|
||||||
|
public virtual Class Class { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Race))]
|
||||||
|
public int RaceId { get; set; }
|
||||||
|
public virtual Race Race { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Alignment))]
|
||||||
|
public int AlignmentId { get; set; }
|
||||||
|
public virtual Alignment Alignment { get; set; }
|
||||||
|
|
||||||
|
[ForeignKey(nameof(Background))]
|
||||||
|
public int BackgroundId { get; set; }
|
||||||
|
public virtual Background Background { get; set; }
|
||||||
|
|
||||||
|
public string Sex { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Character : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(User))]
|
||||||
|
public int UserId { get; set; }
|
||||||
|
public virtual User User { get; set; }
|
||||||
|
public virtual Biography Biography { get; set; }
|
||||||
|
public virtual Statistics Statistics { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
SessionCompanion/SessionCompanion.Database/Tables/Class.cs
Normal file
14
SessionCompanion/SessionCompanion.Database/Tables/Class.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Class : BaseEntity
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
//public int HitDie { get; set; }
|
||||||
|
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
12
SessionCompanion/SessionCompanion.Database/Tables/Race.cs
Normal file
12
SessionCompanion/SessionCompanion.Database/Tables/Race.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Race : BaseEntity
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public virtual ICollection<Biography> Biography { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class Statistics : BaseEntity
|
||||||
|
{
|
||||||
|
[ForeignKey(nameof(Character))]
|
||||||
|
public int CharacterId { get; set; }
|
||||||
|
public virtual Character Character { get; set; }
|
||||||
|
|
||||||
|
public int ExperiencePoints { get; set; }
|
||||||
|
public int Level { get; set; }
|
||||||
|
public int Speed { get; set; }
|
||||||
|
public int Initiative { get; set; }
|
||||||
|
public int HealthPoints { get; set; }
|
||||||
|
public int CurrentHealthPoints { get; set; }
|
||||||
|
public int ArmorClass { get; set; }
|
||||||
|
public int Proficiency { get; set; }
|
||||||
|
}
|
||||||
|
}
|
13
SessionCompanion/SessionCompanion.Database/Tables/User.cs
Normal file
13
SessionCompanion/SessionCompanion.Database/Tables/User.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace SessionCompanion.Database.Tables
|
||||||
|
{
|
||||||
|
public class User : BaseEntity
|
||||||
|
{
|
||||||
|
public string Nickname { get; set; }
|
||||||
|
public string Password { get; set; }
|
||||||
|
public ICollection<Character> Character { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,25 +1,31 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
# Visual Studio Version 16
|
# Visual Studio Version 16
|
||||||
VisualStudioVersion = 16.0.30717.126
|
VisualStudioVersion = 16.0.30717.126
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion", "SessionCompanion\SessionCompanion.csproj", "{C646135F-16CE-4B16-B041-252D343D4E01}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SessionCompanion", "SessionCompanion\SessionCompanion.csproj", "{C646135F-16CE-4B16-B041-252D343D4E01}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SessionCompanion.Database", "SessionCompanion.Database\SessionCompanion.Database.csproj", "{CA05189B-A4AB-4946-80DC-EFA075A10F09}"
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
EndProject
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Global
|
||||||
Release|Any CPU = Release|Any CPU
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
EndGlobalSection
|
Debug|Any CPU = Debug|Any CPU
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
Release|Any CPU = Release|Any CPU
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
EndGlobalSection
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
EndGlobalSection
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
{C646135F-16CE-4B16-B041-252D343D4E01}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
HideSolutionNode = FALSE
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
EndGlobalSection
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
SolutionGuid = {121AE434-C579-4495-9318-0D7D7DBE0FD8}
|
{CA05189B-A4AB-4946-80DC-EFA075A10F09}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
|
SolutionGuid = {121AE434-C579-4495-9318-0D7D7DBE0FD8}
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
|
Loading…
Reference in New Issue
Block a user