Compare commits

...

105 Commits

Author SHA1 Message Date
Natalia Gawron 50236f8ea0 Merge pull request 'SES-88 Created User register connection' (#29) from SES-88 into master
Reviewed-on: #29
2020-12-13 19:41:33 +01:00
Łukasz Góreczny 2b4cd79484 SES-88 Created User register connection 2020-12-13 19:27:28 +01:00
Łukasz Góreczny 79f6bede98 Merge pull request 'SES-84 Created User registration method' (#27) from SES-84 into master
Reviewed-on: #27
2020-12-13 17:07:55 +01:00
Łukasz Góreczny c9a4e7aa0d Merge branch 'master' into SES-84 2020-12-13 13:30:33 +01:00
Natalia Gawron 73f01e8e2c Merge pull request 'SES-89 Connected to backend for login' (#28) from SES-89 into master
Reviewed-on: #28
2020-12-13 13:29:18 +01:00
Łukasz Góreczny 57759fb91e SES-89 type change 2020-12-13 13:27:45 +01:00
Łukasz Góreczny 815bd676d1 SES-84 Change type to Either 2020-12-13 13:22:09 +01:00
Łukasz Góreczny 1412362b79 SES-89 Switched to subscribe 2020-12-13 13:05:08 +01:00
Kosma 6f8cf6dcb4 UserController.cs change 2020-12-13 12:45:50 +01:00
Łukasz Góreczny b9928d6ce0 SES-89 Added api connection service and display error 2020-12-13 11:19:01 +01:00
Natalia Gawron 7b122e160e Merge pull request 'SES-90 Added Game Master component' (#26) from SES-90 into master
Reviewed-on: #26
2020-12-12 19:39:36 +01:00
Łukasz Góreczny 479fd2114b SES-90 Confilcts resolve 2020-12-12 19:24:18 +01:00
Łukasz Góreczny fcfd8665c2 Merge pull request 'SES-86 added Sign Up Component' (#25) from SES-86 into master
Reviewed-on: #25
2020-12-12 19:20:23 +01:00
Łukasz Góreczny a4ed6faa05 SES-90 Added Game master component 2020-12-12 19:06:30 +01:00
Natalia Gawron 4ed509bd0a SES-86 added validator into sign in and sing up components, changed styles 2020-12-12 18:51:08 +01:00
Łukasz Góreczny 0fd20fd2b1 SES-90 Styles changes 2020-12-12 11:16:25 +01:00
Natalia Gawron 530c49f1b7 SES-86 added Sign Up Component 2020-12-12 00:21:06 +01:00
Łukasz Góreczny e6b632f8f6 Merge pull request 'SES-87 defined default style, created LoginUI component' (#24) from SES-87 into master
Reviewed-on: #24
2020-12-11 22:08:22 +01:00
Natalia Gawron e83bc3fa73 Merge branch 'master' into SES-87 2020-12-11 22:05:39 +01:00
Natalia Gawron 012c8828e1 SES-87 defined default style, created LoginUI component 2020-12-11 21:58:24 +01:00
Łukasz Góreczny 663b33e4a8 Merge pull request 'SES-81 Rozdzielenie back of front' (#23) from SES-81 into master
Reviewed-on: #23
2020-12-11 20:16:13 +01:00
Karol Górzyński fde1196069 Merge branch 'master' into SES-81 2020-12-11 19:20:39 +01:00
Karol Górzyński cd1a0af239 Merge pull request 'SES-91 Utworzenie modelu zwrotek AP oraz zajmowanie się domyślnymi exceptionami' (#22) from SES-91 into master
Reviewed-on: #22
2020-12-11 17:08:07 +01:00
Łukasz Góreczny b0e0e5c5f5 Merge branch 'SES-91' of git.wmi.amu.edu.pl:s426135/session-companion into SES-91 2020-12-11 11:11:06 +01:00
Łukasz Góreczny 81aebe44de SES-91 Added documentation and extra method 2020-12-11 11:10:51 +01:00
Karol Górzyński 3c57f7770e Merge branch 'master' into SES-91 2020-12-10 17:41:24 +01:00
Łukasz Góreczny db2de42824 końcowe poprawki 2020-12-10 17:34:46 +01:00
Łukasz Góreczny 8e59538db8 Utworzenie modeli success i error 2020-12-10 17:34:30 +01:00
kargor8 553a27a92a Useless commit to see if jenkins works 2020-12-10 17:32:32 +01:00
kargor8 712f87c696 Try npm cache clean 2020-12-10 17:30:06 +01:00
kargor8 0c0bdc70e5 Delete whats left and build npm, fix typo 2020-12-10 17:19:15 +01:00
kargor8 8530f3e940 Delete whats left and build npm 2020-12-10 17:18:02 +01:00
kargor8 c96dd4f567 Jenkins now lets build frontend and backend 2020-12-10 17:09:46 +01:00
Łukasz Góreczny 9efefd96fe SES-91 Added error middleware 2020-12-10 15:28:00 +01:00
Łukasz Góreczny 6131bbe706 New Type moved to different project and changed on of the profiles 2020-12-10 15:08:05 +01:00
Łukasz Góreczny bc6709e905 Small fix 2020-12-10 14:31:40 +01:00
Łukasz Góreczny 2cac5bd829 Fix mapper 2020-12-10 13:55:31 +01:00
Łukasz Góreczny 09b7db8aaf Added Either return type 2020-12-10 13:15:11 +01:00
Łukasz Góreczny 68200162da Merge pull request 'login endpoint SES-85' (#21) from SES-85 into master
Reviewed-on: #21
2020-12-10 12:52:32 +01:00
Kosma 572b48c15e UserService.cs edit 2020-12-09 23:09:57 +01:00
Kosma 4580c2fe17 login endpoint 2020-12-09 22:47:25 +01:00
Karol Górzyński 1dc09fae4e Merge pull request 'SES-82 Added description to view models' (#20) from SES-82 into master
Reviewed-on: #20
2020-12-09 17:20:09 +01:00
Łukasz Góreczny 544b8a1982 SES-82 Added description to view models 2020-12-09 09:44:52 +01:00
Łukasz Góreczny eefab76c50 Merge pull request 'added base service' (#19) from SES-76 into master
Reviewed-on: #19
2020-12-07 11:47:38 +01:00
ngawron 5d8f5578c3 added base service 2020-12-07 11:46:18 +01:00
Karol Górzyński 247ce78c2b Merge pull request 'SES-80 Added swagger base configuration' (#18) from SES-80 into master
Reviewed-on: #18
2020-12-06 17:04:12 +01:00
Łukasz Góreczny 31db5c9b73 Added swagger base configuration 2020-12-06 16:28:16 +01:00
Karol Górzyński e65ad753ad Merge pull request 'Changed method to check if GM is already logged' (#15) from SES-78 into master
Reviewed-on: #15
2020-12-06 15:42:00 +01:00
Karol Górzyński 8712191acc Resolve conflicts 2020-12-06 15:41:18 +01:00
Karol Górzyński 5ed3e025ec Merge pull request 'SES-70 Added Automapper and Profiles' (#16) from SES-70 into master
Reviewed-on: #16
2020-12-06 15:33:14 +01:00
Karol Górzyński 33a51eef3f Merge branch 'master' into SES-70 2020-12-06 15:33:08 +01:00
Karol Górzyński ccfdff6791 Merge pull request 'SES-69 Added controllers and comments' (#17) from SES-69 into master
Reviewed-on: #17
2020-12-06 15:29:12 +01:00
Łukasz Góreczny 46b2d54f26 Small fixes to prepare project for swagger 2020-12-06 14:34:56 +01:00
Łukasz Góreczny 6cc4ed74a9 SES-69 Added controllers and one method 2020-12-06 14:34:19 +01:00
Łukasz Góreczny a35e2ed567 Added AutoMapper 2020-12-06 11:28:57 +01:00
Łukasz Góreczny e6a6ac290a Dodanie profili 2020-12-06 11:21:33 +01:00
Łukasz Góreczny 71687cafad Changed method to check if GM is allready logged 2020-12-06 11:01:49 +01:00
Łukasz Góreczny b6a80a2e89 Merge pull request 'SES-75 added router into sign-in page' (#13) from SES-75 into master
Reviewed-on: #13
2020-12-06 08:59:07 +01:00
Łukasz Góreczny c55f504741 Merge pull request 'SES-66 Services' (#14) from SES-66 into master
Reviewed-on: #14
2020-12-06 08:58:31 +01:00
Karol Górzyński 2db796f3dc Add services and configruations for them 2020-12-05 21:59:32 +01:00
Karol Górzyński f957654596 Add interfaces 2020-12-05 21:47:12 +01:00
Karol Górzyński 4aea17277a Added base interface and service 2020-12-05 21:46:27 +01:00
Karol Górzyński e2b55ada11 Added project for services in .net 5.0 2020-12-05 21:35:31 +01:00
Karol Górzyński 6ed0708e49 Merge pull request 'SES-77' (#12) from SES-77 into master
Reviewed-on: #12
2020-12-05 21:32:04 +01:00
Karol Górzyński e27ccdd05d Merge branch 'master' into SES-77 2020-12-05 21:31:34 +01:00
ngawron 2d152df1b1 SES-75 added router into sign-in page 2020-12-05 20:24:34 +01:00
Łukasz Góreczny a88dfaa54f SES-77 Aded singlaR methods for register and override default disconnect 2020-12-05 19:18:45 +01:00
Łukasz Góreczny 8ccdcb955e Merge pull request 'SES-74' (#8) from SES-74 into master
Reviewed-on: #8
2020-12-05 19:00:58 +01:00
Łukasz Góreczny a53f35a90a SES-74 Rebase 2020-12-05 18:59:14 +01:00
ngawron ceb836d734 deleted unused files, added changes after PR, fixed database property 2020-12-05 18:58:47 +01:00
ngawron b5c37e40e4 SES-74 created master-page with - select role 2020-12-05 18:58:04 +01:00
ngawron b2387e0cc0 SES-74 added basic structure to the code 2020-12-05 18:58:03 +01:00
Łukasz Góreczny 561b688519 SES-77 SignalR base config 2020-12-05 18:55:35 +01:00
ngawron 6cb742caa2 deleted unused files, added changes after PR, fixed database property 2020-12-05 18:50:48 +01:00
Łukasz Góreczny 21710903ed Merge pull request 'SES-67' (#11) from SES-67 into master
Reviewed-on: #11
2020-12-05 16:40:08 +01:00
Łukasz Góreczny 4793312858 Merge branch 'SES-67' of git.wmi.amu.edu.pl:s426135/session-companion into SES-67 2020-12-05 16:39:04 +01:00
Karol Górzyński e53d87416b Fix some weird bug with Visualstudio 2020-12-05 16:35:55 +01:00
Kosma 53c2d7cfcc added repositories 2020-12-05 16:35:54 +01:00
Karol Górzyński f0c14da49c Merge pull request 'added ViewModels' (#10) from SES-68 into master
Reviewed-on: #10
2020-12-05 16:17:35 +01:00
Karol Górzyński 0196595df2 Merge branch 'master' into SES-68 2020-12-05 14:02:50 +01:00
Karol Górzyński cd63f5e402 Again bug with vs 2020-12-05 14:01:46 +01:00
Karol Górzyński 18fe024fd1 Merge branch 'SES-68' of git.wmi.amu.edu.pl:s426135/session-companion into SES-68 2020-12-05 14:01:03 +01:00
Karol Górzyński 333283443e Change ViewModels to 5.0 2020-12-05 13:55:07 +01:00
Karol Górzyński b242455a88 Fix some weird bug with Visualstudio 2020-12-05 12:34:23 +01:00
Karol Górzyński d6c7107915 Fixed errors with not merging and bad project version 2020-12-05 12:32:30 +01:00
Karol Górzyński 9dfac7d081 Merge branch 'master' of git.wmi.amu.edu.pl:s426135/session-companion into SES-67 2020-12-05 12:29:51 +01:00
Kosma 553232acf7 added repositories 2020-12-05 11:33:34 +01:00
Kosma 7860c1d535 added ViewModels 2020-12-04 21:34:30 +01:00
Łukasz Góreczny 84616f3344 Merge pull request 'dodano tabele atrybutow postaci' (#9) from SES-65 into master
Reviewed-on: #9
2020-12-04 17:04:25 +01:00
Kosma a303a7da7e dodano tabele atrybutow postaci 2020-12-04 15:49:51 +01:00
Łukasz Góreczny 422d794d79 Merge pull request 'SES-67' (#6) from SES-67 into master
Reviewed-on: #6
2020-12-03 22:35:20 +01:00
Karol Górzyński 501738f247 Merged but i think its not as good as you think 2020-12-03 22:32:42 +01:00
ngawron afe73424df SES-74 created master-page with - select role 2020-12-03 22:31:43 +01:00
Łukasz Góreczny ebb250bd88 Merge pull request 'SES-68 Added Basic ViewModels' (#7) from SES-68 into master
Reviewed-on: #7
2020-12-03 22:21:45 +01:00
Karol Górzyński 850ae8e610 SES-68 Changes to csproj 2020-12-03 21:30:34 +01:00
ngawron bdeca6efbe SES-74 added basic structure to the code 2020-12-03 21:03:58 +01:00
Karol Górzyński f123ef65eb SES-68 Added Basic ViewModels 2020-12-03 19:22:35 +01:00
Karol Górzyński dfc3cdac98 SES-67 Add config to repositories 2020-12-03 18:52:53 +01:00
Karol Górzyński e3bcf28f46 SES-67 Add repostitories 2020-12-03 18:52:19 +01:00
Łukasz Góreczny d2d8bd8cab Merge pull request 'SES-65' (#5) from SES-65 into master
Reviewed-on: #5
2020-12-03 18:36:38 +01:00
Karol Górzyński f455c985d2 Add migration usage 2020-12-03 17:58:52 +01:00
Karol Górzyński 50a11e0434 Add new class to have cleaner code 2020-12-03 17:50:11 +01:00
Karol Górzyński 13e0e77b52 SES-65 Working database 2020-12-03 17:13:17 +01:00
Karol Górzyński d59c20bd0b Fix bug with bad intending 2020-12-03 17:00:04 +01:00
Karol Górzyński 7e15254cc1 Added Some based tables and new project 2020-12-02 23:05:06 +01:00
160 changed files with 7074 additions and 317 deletions

55
Jenkinsfile vendored
View File

@ -1,21 +1,34 @@
pipeline {
agent any
stages {
stage('Build image') {
steps {
echo "Building docker image"
script {
dir('SessionCompanion/SessionCompanion'){
def customImage = docker.build("session-companion:${env.BUILD_ID}")
//customImage.withRun('-p 5050:5050')
}
}
}
}
stage('Delete image') {
steps {
sh "docker rmi session-companion:${env.BUILD_ID}"
}
}
}
}
pipeline {
agent {
docker {
image 'kargor8/sess-comp-base:v2'
}
}
environment {
DOTNET_CLI_HOME = '/tmp/App'
}
stages {
stage('Build app') {
steps {
dir('SessionCompanion') {
sh "echo $USER"
withEnv(["HOME=${env.WORKSPACE}"]){
dir ('SessionCompanion/ClientApp') {
sh 'npm cache clean --force'
sh 'npm install'
}
sh 'dotnet build'
}
}
}
}
stage('Clear') {
steps {
withEnv(["HOME=${env.WORKSPACE}"]){
sh 'rm -rf .local'
}
}
}
}
}

View File

@ -0,0 +1,36 @@
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<Charisma> Charismas { get; set; }
public virtual DbSet<Class> Classes { get; set; }
public virtual DbSet<Constitution> Constitutions { get; set; }
public virtual DbSet<Dexterity> Dexterities { get; set; }
public virtual DbSet<Intelligence> Intelligences { get; set; }
public virtual DbSet<Race> Races { get; set; }
public virtual DbSet<Statistics> Statistics { get; set; }
public virtual DbSet<Strength> Strengths { get; set; }
public virtual DbSet<User> Users { get; set; }
public virtual DbSet<Wisdom> Wisdoms { get; set; }
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<User>().HasData(SeedData.SeedUsers());
}
}
}

View File

@ -0,0 +1,317 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SessionCompanion.Database;
namespace SessionCompanion.Database.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20201203161115_Base-Tables")]
partial class BaseTables
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Alignments");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Backgrounds");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AlignmentId")
.HasColumnType("int");
b.Property<int>("BackgroundId")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("ClassId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int>("RaceId")
.HasColumnType("int");
b.Property<string>("Sex")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AlignmentId");
b.HasIndex("BackgroundId");
b.HasIndex("CharacterId")
.IsUnique();
b.HasIndex("ClassId");
b.HasIndex("RaceId");
b.ToTable("Biographies");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Characters");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Classes");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Races");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("ArmorClass")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("CurrentHealthPoints")
.HasColumnType("int");
b.Property<int>("ExperiencePoints")
.HasColumnType("int");
b.Property<int>("HealthPoints")
.HasColumnType("int");
b.Property<int>("Initiative")
.HasColumnType("int");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("Proficiency")
.HasColumnType("int");
b.Property<int>("Speed")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Statistics");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Nickname")
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Nickname = "Morwiec",
Password = "123"
},
new
{
Id = 2,
Nickname = "Cichoklepiec",
Password = "123"
},
new
{
Id = 3,
Nickname = "Ruletka",
Password = "123"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
.WithMany("Biography")
.HasForeignKey("AlignmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
.WithMany("Biography")
.HasForeignKey("BackgroundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Biography")
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
.WithMany("Biography")
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
.WithMany("Biography")
.HasForeignKey("RaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Alignment");
b.Navigation("Background");
b.Navigation("Character");
b.Navigation("Class");
b.Navigation("Race");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.HasOne("SessionCompanion.Database.Tables.User", "User")
.WithMany("Character")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Statistics")
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Navigation("Biography");
b.Navigation("Statistics");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Navigation("Character");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,248 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace SessionCompanion.Database.Migrations
{
public partial class BaseTables : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Alignments",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Alignments", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Backgrounds",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1")
},
constraints: table =>
{
table.PrimaryKey("PK_Backgrounds", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Classes",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Classes", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Races",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Races", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Users",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Nickname = table.Column<string>(type: "nvarchar(max)", nullable: true),
Password = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Users", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Characters",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
UserId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Characters", x => x.Id);
table.ForeignKey(
name: "FK_Characters_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Biographies",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
ClassId = table.Column<int>(type: "int", nullable: false),
RaceId = table.Column<int>(type: "int", nullable: false),
AlignmentId = table.Column<int>(type: "int", nullable: false),
BackgroundId = table.Column<int>(type: "int", nullable: false),
Sex = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Biographies", x => x.Id);
table.ForeignKey(
name: "FK_Biographies_Alignments_AlignmentId",
column: x => x.AlignmentId,
principalTable: "Alignments",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Backgrounds_BackgroundId",
column: x => x.BackgroundId,
principalTable: "Backgrounds",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Classes_ClassId",
column: x => x.ClassId,
principalTable: "Classes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_Biographies_Races_RaceId",
column: x => x.RaceId,
principalTable: "Races",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Statistics",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
ExperiencePoints = table.Column<int>(type: "int", nullable: false),
Level = table.Column<int>(type: "int", nullable: false),
Speed = table.Column<int>(type: "int", nullable: false),
Initiative = table.Column<int>(type: "int", nullable: false),
HealthPoints = table.Column<int>(type: "int", nullable: false),
CurrentHealthPoints = table.Column<int>(type: "int", nullable: false),
ArmorClass = table.Column<int>(type: "int", nullable: false),
Proficiency = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Statistics", x => x.Id);
table.ForeignKey(
name: "FK_Statistics_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 1, "Morwiec", "123" });
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 2, "Cichoklepiec", "123" });
migrationBuilder.InsertData(
table: "Users",
columns: new[] { "Id", "Nickname", "Password" },
values: new object[] { 3, "Ruletka", "123" });
migrationBuilder.CreateIndex(
name: "IX_Biographies_AlignmentId",
table: "Biographies",
column: "AlignmentId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_BackgroundId",
table: "Biographies",
column: "BackgroundId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_CharacterId",
table: "Biographies",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Biographies_ClassId",
table: "Biographies",
column: "ClassId");
migrationBuilder.CreateIndex(
name: "IX_Biographies_RaceId",
table: "Biographies",
column: "RaceId");
migrationBuilder.CreateIndex(
name: "IX_Characters_UserId",
table: "Characters",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_Statistics_CharacterId",
table: "Statistics",
column: "CharacterId",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Biographies");
migrationBuilder.DropTable(
name: "Statistics");
migrationBuilder.DropTable(
name: "Alignments");
migrationBuilder.DropTable(
name: "Backgrounds");
migrationBuilder.DropTable(
name: "Classes");
migrationBuilder.DropTable(
name: "Races");
migrationBuilder.DropTable(
name: "Characters");
migrationBuilder.DropTable(
name: "Users");
}
}
}

View File

@ -0,0 +1,683 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SessionCompanion.Database;
namespace SessionCompanion.Database.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20201213175031_Username column rename")]
partial class Usernamecolumnrename
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Alignments");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Backgrounds");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AlignmentId")
.HasColumnType("int");
b.Property<int>("BackgroundId")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("ClassId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int>("RaceId")
.HasColumnType("int");
b.Property<string>("Sex")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AlignmentId");
b.HasIndex("BackgroundId");
b.HasIndex("CharacterId")
.IsUnique();
b.HasIndex("ClassId");
b.HasIndex("RaceId");
b.ToTable("Biographies");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Characters");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanDeception")
.HasColumnType("bit");
b.Property<bool>("CanIntimidation")
.HasColumnType("bit");
b.Property<bool>("CanPerformance")
.HasColumnType("bit");
b.Property<bool>("CanPersuasion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Deception")
.HasColumnType("int");
b.Property<int>("Intimidation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Performance")
.HasColumnType("int");
b.Property<int>("Persuasion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Charismas");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Classes");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Constitutions");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Acrobatics")
.HasColumnType("int");
b.Property<bool>("CanAcrobatics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSleightOfHand")
.HasColumnType("bit");
b.Property<bool>("CanStealth")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("SleightOfHand")
.HasColumnType("int");
b.Property<int>("Stealth")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Dexterities");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Arcana")
.HasColumnType("int");
b.Property<bool>("CanArcana")
.HasColumnType("bit");
b.Property<bool>("CanHistory")
.HasColumnType("bit");
b.Property<bool>("CanInvestigation")
.HasColumnType("bit");
b.Property<bool>("CanNature")
.HasColumnType("bit");
b.Property<bool>("CanReligion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("History")
.HasColumnType("int");
b.Property<int>("Investigation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Nature")
.HasColumnType("int");
b.Property<int>("Religion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Intelligences");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Races");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("ArmorClass")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("CurrentHealthPoints")
.HasColumnType("int");
b.Property<int>("ExperiencePoints")
.HasColumnType("int");
b.Property<int>("HealthPoints")
.HasColumnType("int");
b.Property<int>("Initiative")
.HasColumnType("int");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("Proficiency")
.HasColumnType("int");
b.Property<int>("Speed")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Statistics");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Athletics")
.HasColumnType("int");
b.Property<bool>("CanAthletics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Strengths");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Password")
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Password = "123",
Username = "Morwiec"
},
new
{
Id = 2,
Password = "123",
Username = "Cichoklepiec"
},
new
{
Id = 3,
Password = "123",
Username = "Ruletka"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AnimalHandling")
.HasColumnType("int");
b.Property<bool>("CanAnimalHandling")
.HasColumnType("bit");
b.Property<bool>("CanInsight")
.HasColumnType("bit");
b.Property<bool>("CanMedicine")
.HasColumnType("bit");
b.Property<bool>("CanPerception")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSurvival")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Insight")
.HasColumnType("int");
b.Property<int>("Medicine")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Perception")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Survival")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Wisdoms");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
.WithMany("Biography")
.HasForeignKey("AlignmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
.WithMany("Biography")
.HasForeignKey("BackgroundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Biography")
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
.WithMany("Biography")
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
.WithMany("Biography")
.HasForeignKey("RaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Alignment");
b.Navigation("Background");
b.Navigation("Character");
b.Navigation("Class");
b.Navigation("Race");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.HasOne("SessionCompanion.Database.Tables.User", "User")
.WithMany("Character")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Charisma")
.HasForeignKey("SessionCompanion.Database.Tables.Charisma", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Constitution")
.HasForeignKey("SessionCompanion.Database.Tables.Constitution", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Dexterity")
.HasForeignKey("SessionCompanion.Database.Tables.Dexterity", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Intelligence")
.HasForeignKey("SessionCompanion.Database.Tables.Intelligence", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Statistics")
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Strength")
.HasForeignKey("SessionCompanion.Database.Tables.Strength", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Wisdom")
.HasForeignKey("SessionCompanion.Database.Tables.Wisdom", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Navigation("Biography");
b.Navigation("Charisma");
b.Navigation("Constitution");
b.Navigation("Dexterity");
b.Navigation("Intelligence");
b.Navigation("Statistics");
b.Navigation("Strength");
b.Navigation("Wisdom");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Navigation("Character");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,251 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace SessionCompanion.Database.Migrations
{
public partial class Usernamecolumnrename : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.RenameColumn(
name: "Nickname",
table: "Users",
newName: "Username");
migrationBuilder.CreateTable(
name: "Charismas",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false),
Deception = table.Column<int>(type: "int", nullable: false),
CanDeception = table.Column<bool>(type: "bit", nullable: false),
Intimidation = table.Column<int>(type: "int", nullable: false),
CanIntimidation = table.Column<bool>(type: "bit", nullable: false),
Performance = table.Column<int>(type: "int", nullable: false),
CanPerformance = table.Column<bool>(type: "bit", nullable: false),
Persuasion = table.Column<int>(type: "int", nullable: false),
CanPersuasion = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Charismas", x => x.Id);
table.ForeignKey(
name: "FK_Charismas_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Constitutions",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Constitutions", x => x.Id);
table.ForeignKey(
name: "FK_Constitutions_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Dexterities",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false),
Acrobatics = table.Column<int>(type: "int", nullable: false),
CanAcrobatics = table.Column<bool>(type: "bit", nullable: false),
SleightOfHand = table.Column<int>(type: "int", nullable: false),
CanSleightOfHand = table.Column<bool>(type: "bit", nullable: false),
Stealth = table.Column<int>(type: "int", nullable: false),
CanStealth = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Dexterities", x => x.Id);
table.ForeignKey(
name: "FK_Dexterities_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Intelligences",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false),
Arcana = table.Column<int>(type: "int", nullable: false),
CanArcana = table.Column<bool>(type: "bit", nullable: false),
History = table.Column<int>(type: "int", nullable: false),
CanHistory = table.Column<bool>(type: "bit", nullable: false),
Investigation = table.Column<int>(type: "int", nullable: false),
CanInvestigation = table.Column<bool>(type: "bit", nullable: false),
Nature = table.Column<int>(type: "int", nullable: false),
CanNature = table.Column<bool>(type: "bit", nullable: false),
Religion = table.Column<int>(type: "int", nullable: false),
CanReligion = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Intelligences", x => x.Id);
table.ForeignKey(
name: "FK_Intelligences_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Strengths",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false),
Athletics = table.Column<int>(type: "int", nullable: false),
CanAthletics = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Strengths", x => x.Id);
table.ForeignKey(
name: "FK_Strengths_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "Wisdoms",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CharacterId = table.Column<int>(type: "int", nullable: false),
Value = table.Column<int>(type: "int", nullable: false),
Modification = table.Column<int>(type: "int", nullable: false),
SavingThrows = table.Column<int>(type: "int", nullable: false),
CanSaveThrows = table.Column<bool>(type: "bit", nullable: false),
AnimalHandling = table.Column<int>(type: "int", nullable: false),
CanAnimalHandling = table.Column<bool>(type: "bit", nullable: false),
Insight = table.Column<int>(type: "int", nullable: false),
CanInsight = table.Column<bool>(type: "bit", nullable: false),
Medicine = table.Column<int>(type: "int", nullable: false),
CanMedicine = table.Column<bool>(type: "bit", nullable: false),
Perception = table.Column<int>(type: "int", nullable: false),
CanPerception = table.Column<bool>(type: "bit", nullable: false),
Survival = table.Column<int>(type: "int", nullable: false),
CanSurvival = table.Column<bool>(type: "bit", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Wisdoms", x => x.Id);
table.ForeignKey(
name: "FK_Wisdoms_Characters_CharacterId",
column: x => x.CharacterId,
principalTable: "Characters",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Charismas_CharacterId",
table: "Charismas",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Constitutions_CharacterId",
table: "Constitutions",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Dexterities_CharacterId",
table: "Dexterities",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Intelligences_CharacterId",
table: "Intelligences",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Strengths_CharacterId",
table: "Strengths",
column: "CharacterId",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Wisdoms_CharacterId",
table: "Wisdoms",
column: "CharacterId",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Charismas");
migrationBuilder.DropTable(
name: "Constitutions");
migrationBuilder.DropTable(
name: "Dexterities");
migrationBuilder.DropTable(
name: "Intelligences");
migrationBuilder.DropTable(
name: "Strengths");
migrationBuilder.DropTable(
name: "Wisdoms");
migrationBuilder.RenameColumn(
name: "Username",
table: "Users",
newName: "Nickname");
}
}
}

View File

@ -0,0 +1,681 @@
// <auto-generated />
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using SessionCompanion.Database;
namespace SessionCompanion.Database.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.UseIdentityColumns()
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.0");
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Alignments");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.HasKey("Id");
b.ToTable("Backgrounds");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AlignmentId")
.HasColumnType("int");
b.Property<int>("BackgroundId")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("ClassId")
.HasColumnType("int");
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.Property<int>("RaceId")
.HasColumnType("int");
b.Property<string>("Sex")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("AlignmentId");
b.HasIndex("BackgroundId");
b.HasIndex("CharacterId")
.IsUnique();
b.HasIndex("ClassId");
b.HasIndex("RaceId");
b.ToTable("Biographies");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("Characters");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanDeception")
.HasColumnType("bit");
b.Property<bool>("CanIntimidation")
.HasColumnType("bit");
b.Property<bool>("CanPerformance")
.HasColumnType("bit");
b.Property<bool>("CanPersuasion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Deception")
.HasColumnType("int");
b.Property<int>("Intimidation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Performance")
.HasColumnType("int");
b.Property<int>("Persuasion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Charismas");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Classes");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Constitutions");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Acrobatics")
.HasColumnType("int");
b.Property<bool>("CanAcrobatics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSleightOfHand")
.HasColumnType("bit");
b.Property<bool>("CanStealth")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("SleightOfHand")
.HasColumnType("int");
b.Property<int>("Stealth")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Dexterities");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Arcana")
.HasColumnType("int");
b.Property<bool>("CanArcana")
.HasColumnType("bit");
b.Property<bool>("CanHistory")
.HasColumnType("bit");
b.Property<bool>("CanInvestigation")
.HasColumnType("bit");
b.Property<bool>("CanNature")
.HasColumnType("bit");
b.Property<bool>("CanReligion")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("History")
.HasColumnType("int");
b.Property<int>("Investigation")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Nature")
.HasColumnType("int");
b.Property<int>("Religion")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Intelligences");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Races");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("ArmorClass")
.HasColumnType("int");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("CurrentHealthPoints")
.HasColumnType("int");
b.Property<int>("ExperiencePoints")
.HasColumnType("int");
b.Property<int>("HealthPoints")
.HasColumnType("int");
b.Property<int>("Initiative")
.HasColumnType("int");
b.Property<int>("Level")
.HasColumnType("int");
b.Property<int>("Proficiency")
.HasColumnType("int");
b.Property<int>("Speed")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Statistics");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("Athletics")
.HasColumnType("int");
b.Property<bool>("CanAthletics")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Strengths");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<string>("Password")
.HasColumnType("nvarchar(max)");
b.Property<string>("Username")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 1,
Password = "123",
Username = "Morwiec"
},
new
{
Id = 2,
Password = "123",
Username = "Cichoklepiec"
},
new
{
Id = 3,
Password = "123",
Username = "Ruletka"
});
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.UseIdentityColumn();
b.Property<int>("AnimalHandling")
.HasColumnType("int");
b.Property<bool>("CanAnimalHandling")
.HasColumnType("bit");
b.Property<bool>("CanInsight")
.HasColumnType("bit");
b.Property<bool>("CanMedicine")
.HasColumnType("bit");
b.Property<bool>("CanPerception")
.HasColumnType("bit");
b.Property<bool>("CanSaveThrows")
.HasColumnType("bit");
b.Property<bool>("CanSurvival")
.HasColumnType("bit");
b.Property<int>("CharacterId")
.HasColumnType("int");
b.Property<int>("Insight")
.HasColumnType("int");
b.Property<int>("Medicine")
.HasColumnType("int");
b.Property<int>("Modification")
.HasColumnType("int");
b.Property<int>("Perception")
.HasColumnType("int");
b.Property<int>("SavingThrows")
.HasColumnType("int");
b.Property<int>("Survival")
.HasColumnType("int");
b.Property<int>("Value")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CharacterId")
.IsUnique();
b.ToTable("Wisdoms");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Biography", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Alignment", "Alignment")
.WithMany("Biography")
.HasForeignKey("AlignmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Background", "Background")
.WithMany("Biography")
.HasForeignKey("BackgroundId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Biography")
.HasForeignKey("SessionCompanion.Database.Tables.Biography", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Class", "Class")
.WithMany("Biography")
.HasForeignKey("ClassId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SessionCompanion.Database.Tables.Race", "Race")
.WithMany("Biography")
.HasForeignKey("RaceId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Alignment");
b.Navigation("Background");
b.Navigation("Character");
b.Navigation("Class");
b.Navigation("Race");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.HasOne("SessionCompanion.Database.Tables.User", "User")
.WithMany("Character")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Charisma", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Charisma")
.HasForeignKey("SessionCompanion.Database.Tables.Charisma", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Constitution", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Constitution")
.HasForeignKey("SessionCompanion.Database.Tables.Constitution", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Dexterity", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Dexterity")
.HasForeignKey("SessionCompanion.Database.Tables.Dexterity", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Intelligence", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Intelligence")
.HasForeignKey("SessionCompanion.Database.Tables.Intelligence", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Statistics", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Statistics")
.HasForeignKey("SessionCompanion.Database.Tables.Statistics", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Strength", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Strength")
.HasForeignKey("SessionCompanion.Database.Tables.Strength", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Wisdom", b =>
{
b.HasOne("SessionCompanion.Database.Tables.Character", "Character")
.WithOne("Wisdom")
.HasForeignKey("SessionCompanion.Database.Tables.Wisdom", "CharacterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Character");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Alignment", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Background", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Character", b =>
{
b.Navigation("Biography");
b.Navigation("Charisma");
b.Navigation("Constitution");
b.Navigation("Dexterity");
b.Navigation("Intelligence");
b.Navigation("Statistics");
b.Navigation("Strength");
b.Navigation("Wisdom");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Class", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.Race", b =>
{
b.Navigation("Biography");
});
modelBuilder.Entity("SessionCompanion.Database.Tables.User", b =>
{
b.Navigation("Character");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class AlignmentRepository : Repository<Alignment>, IRepository<Alignment>
{
public AlignmentRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class BackgroundRepository : Repository<Background>, IRepository<Background>
{
public BackgroundRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,24 @@
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Database.Repositories.Base
{
public interface IRepository<T> where T : BaseEntity
{
IQueryable<T> Get();
IQueryable<T> Get(Expression<Func<T, bool>> expression);
Task<T> Get(int id);
Task Create(T entity);
Task Update(T entity);
void Delete(T entity);
Task<bool> Any(Expression<Func<T, bool>> expression);
Task<bool> Any(int id);
void Dispose();
Task Save();
}
}

View File

@ -0,0 +1,72 @@
using Microsoft.EntityFrameworkCore;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Database.Repositories.Base
{
public class Repository<T> : IRepository<T> where T : BaseEntity
{
protected ApplicationDbContext RepositoryContext { get; set; }
public Repository(ApplicationDbContext repositoryContext)
{
this.RepositoryContext = repositoryContext;
}
public IQueryable<T> Get()
{
return this.RepositoryContext.Set<T>();
}
public IQueryable<T> Get(Expression<Func<T, bool>> expression)
{
return this.RepositoryContext.Set<T>().Where(expression);
}
public Task<bool> Any(Expression<Func<T, bool>> expression)
{
return RepositoryContext.Set<T>().AnyAsync(expression);
}
public Task<bool> Any(int id)
{
return RepositoryContext.Set<T>().AnyAsync(n => n.Id == id);
}
public async Task<T> Get(int id)
{
return await RepositoryContext.Set<T>().FindAsync(id);
}
public virtual Task Create(T entity)
{
return Task.FromResult(RepositoryContext.Set<T>().AddAsync(entity));
}
public virtual Task Update(T entity)
{
return Task.FromResult(RepositoryContext.Set<T>().Update(entity));
}
public virtual void Delete(T entity)
{
this.RepositoryContext.Set<T>().Remove(entity);
}
public virtual async Task Save()
{
await RepositoryContext.SaveChangesAsync();
}
public void Dispose()
{
RepositoryContext.Dispose();
}
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class BiographyRepository : Repository<Biography>, IRepository<Biography>
{
public BiographyRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class CharacterRepository : Repository<Character>, IRepository<Character>
{
public CharacterRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class CharismaRepository : Repository<Charisma>, IRepository<Charisma>
{
public CharismaRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class ClassRepository : Repository<Class>, IRepository<Class>
{
public ClassRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class ConstitutionRepository : Repository<Constitution>, IRepository<Constitution>
{
public ConstitutionRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class DexterityRepository : Repository<Dexterity>, IRepository<Dexterity>
{
public DexterityRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class IntelligenceRepository : Repository<Intelligence>, IRepository<Intelligence>
{
public IntelligenceRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class RaceRepository : Repository<Race>, IRepository<Race>
{
public RaceRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class StatisticsRepository : Repository<Statistics>, IRepository<Statistics>
{
public StatisticsRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class StrengthRepository : Repository<Strength>, IRepository<Strength>
{
public StrengthRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class UserRepository : Repository<User>, IRepository<User>
{
public UserRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Repositories
{
public class WisdomRepository : Repository<Wisdom>, IRepository<Wisdom>
{
public WisdomRepository(ApplicationDbContext _dbContext) : base(_dbContext)
{ }
}
}

View File

@ -0,0 +1,39 @@
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 SeedData
{
static public List<User> SeedUsers()
{
List<User> users = new List<User>
{
new User
{
Id = 1,
Username = "Morwiec",
Password = "123"
},
new User
{
Id = 2,
Username = "Cichoklepiec",
Password = "123"
},
new User
{
Id = 3,
Username = "Ruletka",
Password = "123"
}
};
return users;
}
}
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,23 @@
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; }
public virtual Charisma Charisma { get; set; }
public virtual Constitution Constitution { get; set; }
public virtual Dexterity Dexterity { get; set; }
public virtual Intelligence Intelligence { get; set; }
public virtual Strength Strength { get; set; }
public virtual Wisdom Wisdom { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Charisma : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
public int Deception { get; set; }
public bool CanDeception { get; set; }
public int Intimidation { get; set; }
public bool CanIntimidation { get; set; }
public int Performance { get; set; }
public bool CanPerformance { get; set; }
public int Persuasion { get; set; }
public bool CanPersuasion { get; set; }
}
}

View 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; }
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Constitution : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Dexterity : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
public int Acrobatics { get; set; }
public bool CanAcrobatics { get; set; }
public int SleightOfHand { get; set; }
public bool CanSleightOfHand { get; set; }
public int Stealth { get; set; }
public bool CanStealth { get; set; }
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Intelligence : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
public int Arcana { get; set; }
public bool CanArcana { get; set; }
public int History { get; set; }
public bool CanHistory { get; set; }
public int Investigation { get; set; }
public bool CanInvestigation { get; set; }
public int Nature { get; set; }
public bool CanNature { get; set; }
public int Religion { get; set; }
public bool CanReligion { get; set; }
}
}

View 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; }
}
}

View File

@ -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; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Strength : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
public int Athletics { get; set; }
public bool CanAthletics { get; set; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class User : BaseEntity
{
public string Username { get; set; }
public string Password { get; set; }
public ICollection<Character> Character { get; set; }
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
namespace SessionCompanion.Database.Tables
{
public class Wisdom : BaseEntity
{
[ForeignKey(nameof(Character))]
public int CharacterId { get; set; }
public virtual Character Character { get; set; }
public int Value { get; set; }
public int Modification { get; set; }
public int SavingThrows { get; set; }
public bool CanSaveThrows { get; set; }
public int AnimalHandling { get; set; }
public bool CanAnimalHandling { get; set; }
public int Insight { get; set; }
public bool CanInsight { get; set; }
public int Medicine { get; set; }
public bool CanMedicine { get; set; }
public int Perception { get; set; }
public bool CanPerception { get; set; }
public int Survival { get; set; }
public bool CanSurvival { get; set; }
}
}

View File

@ -0,0 +1,119 @@
using System;
namespace SessionCompanion.Extensions.EitherType
{
public class Either<TL, TR>
{
/// <summary>
/// Kontruktor dla lewej zmiennej
/// </summary>
/// <param name="left">Wartość lewej zmiennej</param>
public Either(TL left)
{
this.Left = left;
this.IsLeft = true;
}
/// <summary>
/// Konstruktor dla prawej zmiennej
/// </summary>
/// <param name="right">Wartość prawej zmiennej</param>
public Either(TR right)
{
this.Right = right;
this.IsLeft = false;
}
/// <summary>
/// Lewa zmienna
/// </summary>
public TL Left { get; }
/// <summary>
/// Prawa zmienna
/// </summary>
public TR Right { get; }
/// <summary>
/// Zmienna informujaca czy wykorzystana zostąła zmienna lewa czy prawa
/// </summary>
public bool IsLeft { get; }
/// <summary>
/// Tworzy obiekt typu Either wykorzystując zmienną lewą
/// </summary>
/// <param name="left">Wartość lewej zmiennej</param>
public static implicit operator Either<TL, TR>(TL left) => new Either<TL, TR>(left);
/// <summary>
/// Tworzy obiekt typu Either wykorzystując zmienną prawą
/// </summary>
/// <param name="right">Wartosć prawej zmiennej</param>
public static implicit operator Either<TL, TR>(TR right) => new Either<TL, TR>(right);
/// <summary>
/// Bazowa metoda dopasowania wzorów.
/// Jeśli podana jest wartość lewa, to Match zwróci wynik lewej funkcji, w przeciwnym razie wynik prawej funkcji.
/// </summary>
/// <typeparam name="T">Typ zwracanej wartości</typeparam>
/// <param name="leftFunc">Lewa funkcja </param>
/// <param name="rightFunc">Prawa funkcja</param>
/// <returns>Wynik prawej/lewej funkcji</returns>
public T Match<T>(Func<TL, T> leftFunc, Func<TR, T> rightFunc)
{
if (leftFunc == null)
{
throw new ArgumentNullException(nameof(leftFunc));
}
if (rightFunc == null)
{
throw new ArgumentNullException(nameof(rightFunc));
}
return this.IsLeft ? leftFunc(this.Left) : rightFunc(this.Right);
}
/// <summary>
/// Bazowa metoda dopasowania wzorów.
/// Jeśli podana jest wartość lewa, to Match wykona lewą funkcję, w przeciwnym razie wykona funkcję prawą.
/// </summary>
/// <param name="leftFunc">Lewa funkcja </param>
/// <param name="rightFunc">Prawa funkcja</param>
public void Match(Action<TL> leftFunc, Action<TR> rightFunc)
{
if (leftFunc == null)
{
throw new ArgumentNullException(nameof(leftFunc));
}
if (rightFunc == null)
{
throw new ArgumentNullException(nameof(rightFunc));
}
if (this.IsLeft)
{
leftFunc(this.Left);
}
else
{
rightFunc(this.Right);
}
}
/// <summary>
/// Funkcja ustala czy uzyta została lewa zmienna, jesli tak to zwraca jej wartość inaczej zwraca defaultowy obiekt
/// o typie takim jak lewa zmienna
/// </summary>
/// <returns> Wartosć lewej zmiennej lub defaultową wartość o typie lewej zmiennej</returns>
public TL LeftOrDefault() => this.Match(l => l, r => default(TL));
/// <summary>
/// Funkcja ustala czy uzyta została prawa zmienna, jesli tak to zwraca jej wartość inaczej zwraca defaultowy obiekt
/// o typie takim jak lewa zmienna
/// </summary>
/// <returns> Wartosć lewej zmiennej lub defaultową wartość o typie prawej zmiennej</returns>
public TR RightOrDefault() => this.Match(l => default(TR), r => r);
}
}

View File

@ -0,0 +1,184 @@
# Either
### Jak używać
Either umożliwa nam zwrócenie z metody bądź nawet kontrolera, dwóch możliwych wyników.
Dla ułatwienia zrozumienai poniżej podaję przykłady stosowania.
Jako typ zmiennej zwracanej z api:
W tym przypadku wskazujemy, że nasze api zwróci albo CharacterViewModel albo ErrorResponse
```cs
public async Task<Either<CharacterViewModel, ErrorResponse>> Get(int id)
```
Aby zwrócić ten typ mamy dwie możliwości.
Możemy wywołać metodę z serisu, która ma nam zwrócić CharacterViewModel.
Następnie sprawdzić czy otrzymana wartość CharacerViewModel zawiera jakiekolwiek dane i odpowiednio, jeśli tak to zwracamy otrzymany viewmodel a jeśli nie tworzymy ErrorResponse i zwracamy wynik:
```cs
public async Task<Either<CharacterViewModel, ErrorResponse>> Get(int id)
{
Either<CharacterViewModel, ErrorResponse> result = await _service.Get(id);
if (result.Left != null)
{
return result;
}
else
{
result = new ErrorResponse { StatusCode = 400, Message = "Coś poszło nie tak" };
return result;
}
}
```
W przypadku jesli serwis nie znajdzie wartości otrzymamy:
```json
{
"left":null,
"right":{
"statusCode":400,
"message":"Coś poszło nie tak"},
"isLeft":false}
```
Drugim sposobem jest zmiana działania serwisu:
```cs
public async Task<Either<CharacterViewModel, ErrorResponse>> GetCharacter(int id)
{
var repoResult = await this.Repository.Get(id);
if (repoResult != null)
{
return Mapper.Map<CharacterViewModel>(repoResult);
}
else
{
return new ErrorResponse()
{
StatusCode = 404,
Message = "Coś poszło nie tak"
};
}
}
```
Wtedy kontroler wygląda tak :
```sh
public async Task<Either<CharacterViewModel, ErrorResponse>> Get(int id)
{
return await this._service.GetCharacter(id);
}
```
### Przypisanie nowej wartości
Jeśli z jakiegośpowodu będziemy chcieli zmienić wartość obiektu Either, musimy dokonać tego w taki oto sposób:
```cs
UserViewModel user = new UserViewModel() { Id = 1, Username = "Testowy", Password = "Secret" };
Either<UserViewModel, string> test = "asd";
// zmieniamy wartość Either
test = user;
// Warto zauważyć, że możemy zmienić wartość obiektu znajdujacego się wewnątrz
// którejś ze zmiennej o ile jest on publiczny
test.Left.Username = "test";
// Jednak jeśli dokonamy tego po zmianie wartości obietu na inny pomimo tego, że
// dla kodu jest to ok, to nie zadziała to poprawnie, ponieważ wartość starego obiektu
// jest zmieniana na null(dla boola na false)
test = "asd";
test.Left.Username = "błąd";
```
### LeftOrDefault() oraz RightOrDefault()
Zwracają one wartość wybranej zmiennej bądź jej wartość defaultową.
Dla wiekszości obiektów jest to null, wyjatkiem jest tutaj bool, który zwróci nam false.
```cs
var test = (Either<bool, string>)true;
var a = test.LeftOrDefault(); // zwróci nam true
var b = test.RightOrDefault(); // zwróci nam null
test = "asd";
var c = test.LeftOrDefault(); // zwróci nam false
var d = test.RightOrDefault(); // zwróci nam "asd"
```
### Match
Funkcja ta pozwala nam na odpalenie odpowiedniej metody w zależności od tego jako typ zmiennej jest aktualnie przechowywany w obiekcie Either. Niestety ograniczeniem jest to, ze obie funkcje musza docelowo zwrócić ten sam typ.
```cs
// ładujemy userviewmodel do obiektu Either i wywoływamy matcha pdając dwie funkcje
test = user;
// zwwrócny zostanie string "Test1"
test.Match(this.Test1, this.Test2);
// ładujemy stringa do obiektu Either i wywoływamy matcha pdając dwie funkcje
test = "asd";
// zwwrócny zostanie string "Test2"
test.Match(this.Test1, this.Test2);
public string Test1(UserViewModel viewModel)
{
return "Test1";
}
public string Test2(string text)
{
return "Test2";
}
```
Warto zauważyć, że możemy wykorzystać tutaj lambde by rozszerzyć nasze możliwości:
```cs
test = "asd";
test.Match(
Test1,
second =>
{
int z = Test2(second);
// tutaj możemy robić już co nam się tylko podoba
// pamiętać należy ze finalnie musimy coś zwrócić
// chyba, że nasze obie funkcje są typu void
return z.ToString();
});
public string Test1(UserViewModel viewModel)
{
return "Test1";
}
public int Test2(string text)
{
return 12;
}
```
Możemy też podać jedna funkcję typu void a drugą typu innego np. string albo int:
```cs
y = "";
test = "asd";
test.Match(
Test1,
second =>
{
var x = this.Test2(second);
//jednak nie ma możliwości zwrócenia wartości
// możemy za to zwrócić wyniki do zewnętrznej zmiennej
y = x;
});
public void Test1(UserViewModel viewModel)
{
//...coś robi
}
public string Test2(string text)
{
return "Test2";
}
```

View File

@ -0,0 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Base
{
public interface IServiceBase<TViewModel, TEntity> : IDisposable
{
IEnumerable<TViewModel> Get();
Task<TViewModel> Get(int id);
Task<IEnumerable<TEntity>> Get(Expression<Func<TEntity, bool>> expresssion);
Task Create(TViewModel viewModel);
Task Update(int id, TViewModel viewModel);
Task Delete(int id);
Task SaveAsync();
}
}

View File

@ -0,0 +1,73 @@
using SessionCompanion.Database.Tables;
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using System.Threading.Tasks;
using SessionCompanion.Database.Repositories.Base;
using System.Linq.Expressions;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace SessionCompanion.Services.Base
{
public class ServiceBase<TViewModel, TEntity> : IServiceBase<TViewModel, TEntity> where TEntity : BaseEntity
{
protected IMapper Mapper { get; private set; }
protected IRepository<TEntity> Repository { get; private set; }
public ServiceBase(IMapper mapper, IRepository<TEntity> repository)
{
Mapper = mapper;
Repository = repository;
}
public virtual IEnumerable<TViewModel> Get()
{
var models = Repository.Get();
return Mapper.Map<IEnumerable<TViewModel>>(models);
}
public virtual async Task<TViewModel> Get(int id)
{
var result = await Repository.Get(id);
return Mapper.Map<TViewModel>(result);
}
public virtual async Task<IEnumerable<TEntity>> Get(Expression<Func<TEntity, bool>> expression)
{
var result = await Repository.Get(expression).ToListAsync();
return result;
}
public virtual async Task Create(TViewModel viewModel)
{
var model = Mapper.Map<TEntity>(viewModel);
await Repository.Create(model);
}
public virtual async Task Update(int id, TViewModel viewModel)
{
var model = Mapper.Map<TEntity>(viewModel);
model.Id = id;
await Repository.Update(model);
}
public virtual async Task Delete(int id)
{
var model = await Repository.Get(id);
Repository.Delete(model);
}
public virtual async Task SaveAsync()
{
await Repository.Save();
}
public virtual void Dispose()
{
Repository.Dispose();
}
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.AlignmentViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IAlignmentService : IServiceBase<AlignmentViewModel, Alignment>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.BackgroundViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IBackgroundService : IServiceBase<BackgroundViewModel, Background>
{
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.BiographyViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Interfaces
{
public interface IBiographyService : IServiceBase<BiographyViewModel, Biography>
{
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.CharacterViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Interfaces
{
public interface ICharacterService : IServiceBase<CharacterViewModel, Character>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.CharismaViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface ICharismaService : IServiceBase<CharismaViewModel, Charisma>
{
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.ClassViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Interfaces
{
public interface IClassService : IServiceBase<ClassViewModel, Class>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.ConstitutionViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IConstitutionService : IServiceBase<ConstitutionViewModel, Constitution>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.DexterityViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IDexterityService : IServiceBase<DexterityViewModel, Dexterity>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.IntelligenceViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IIntelligenceService : IServiceBase<IntelligenceViewModel, Intelligence>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.RaceViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IRaceService : IServiceBase<RaceViewModel, Race>
{
}
}

View File

@ -0,0 +1,14 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.StatisticsViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Interfaces
{
public interface IStatisticsService : IServiceBase<StatisticsViewModel, Statistics>
{
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.StrengthViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IStrengthService : IServiceBase<StrengthViewModel, Strength>
{
}
}

View File

@ -0,0 +1,15 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.UserViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Interfaces
{
public interface IUserService : IServiceBase<UserViewModel, User>
{
Task<UserViewModel> SearchUserByUsername(string userName);
}
}

View File

@ -0,0 +1,13 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.ViewModels.WisdomViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Interfaces
{
public interface IWisdomService : IServiceBase<WisdomViewModel, Wisdom>
{
}
}

View File

@ -0,0 +1,20 @@
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.AlignmentViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Profiles
{
class AlignmentProfile : Profile
{
public AlignmentProfile()
{
CreateMap<AlignmentViewModel, Alignment>();
CreateMap<Alignment, AlignmentViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.BackgroundViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Profiles
{
public class BackgroundProfile : Profile
{
public BackgroundProfile()
{
CreateMap<BackgroundViewModel, Background>();
CreateMap<Background, BackgroundViewModel>();
}
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.BiographyViewModels;
namespace SessionCompanion.Services.Profiles
{
public class BiographyProfile : Profile
{
public BiographyProfile()
{
CreateMap<BiographyViewModel, Biography>();
CreateMap<Biography, BiographyViewModel>();
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.CharacterViewModels;
namespace SessionCompanion.Services.Profiles
{
public class CharacterProfile : Profile
{
public CharacterProfile()
{
CreateMap<Character, CharacterViewModel>();
CreateMap<CharacterViewModel, Character>();
CreateMap<Character, CharacterForLoginViewModel>()
.ForMember(vm => vm.Name, conf => conf.MapFrom(charact => charact.Biography.Name))
.ForMember(vm => vm.Level, conf => conf.MapFrom(charact => charact.Statistics.Level))
.ForMember(vm => vm.ClassName, conf => conf.MapFrom(charact => charact.Biography.Class.Name)).ReverseMap();
CreateMap<Character, CharacterBasicStatsViewModel>()
.ForMember(vm => vm.Name, conf => conf.MapFrom(charact => charact.Biography.Name))
.ForMember(vm => vm.Level, conf => conf.MapFrom(charact => charact.Statistics.Level))
.ForMember(vm => vm.CurrentHealthPoints, conf => conf.MapFrom(charact => charact.Statistics.CurrentHealthPoints)).ReverseMap();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.CharismaViewModels;
namespace SessionCompanion.Services.Profiles
{
public class CharismaProfile : Profile
{
public CharismaProfile()
{
CreateMap<CharismaViewModel, Charisma>();
CreateMap<Charisma, CharismaViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.ClassViewModels;
namespace SessionCompanion.Services.Profiles
{
public class ClassProfile : Profile
{
public ClassProfile()
{
CreateMap<ClassViewModel, Class>();
CreateMap<Class, ClassViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.ConstitutionViewModels;
namespace SessionCompanion.Services.Profiles
{
public class ConstitutionProfile : Profile
{
public ConstitutionProfile()
{
CreateMap<ConstitutionViewModel, Constitution>();
CreateMap<Constitution,ConstitutionViewModel > ();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.DexterityViewModels;
namespace SessionCompanion.Services.Profiles
{
public class DexterityProfile : Profile
{
public DexterityProfile()
{
CreateMap<DexterityViewModel, Dexterity>();
CreateMap<Dexterity, DexterityViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.IntelligenceViewModels;
namespace SessionCompanion.Services.Profiles
{
public class IntelligenceProfile : Profile
{
public IntelligenceProfile()
{
CreateMap<IntelligenceViewModel, Intelligence>();
CreateMap<Intelligence, IntelligenceViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.RaceViewModels;
namespace SessionCompanion.Services.Profiles
{
public class RaceProfile : Profile
{
public RaceProfile()
{
CreateMap<Race, RaceViewModel>();
CreateMap<RaceViewModel, Race>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.StatisticsViewModels;
namespace SessionCompanion.Services.Profiles
{
public class StatisticsProfile : Profile
{
public StatisticsProfile()
{
CreateMap<StatisticsViewModel, Statistics>();
CreateMap<Statistics, StatisticsViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.StrengthViewModels;
namespace SessionCompanion.Services.Profiles
{
public class StrengthProfile : Profile
{
public StrengthProfile()
{
CreateMap<StrengthViewModel, Strength>();
CreateMap<Strength, StrengthViewModel>();
}
}
}

View File

@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.UserViewModels;
namespace SessionCompanion.Services.Profiles
{
public class UserProfile : Profile
{
public UserProfile()
{
CreateMap<UserViewModel, User>().ReverseMap();
}
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using SessionCompanion.Database.Tables;
using SessionCompanion.ViewModels.WisdomViewModels;
namespace SessionCompanion.Services.Profiles
{
public class WisdomProfile : Profile
{
public WisdomProfile()
{
CreateMap<WisdomViewModel, Wisdom>();
CreateMap<Wisdom, WisdomViewModel>();
}
}
}

View File

@ -0,0 +1,18 @@
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.AlignmentViewModels;
using AutoMapper;
using System;
using System.Collections.Generic;
using System.Text;
using SessionCompanion.Database.Repositories.Base;
namespace SessionCompanion.Services.Services
{
public class AlignmentService : ServiceBase<AlignmentViewModel, Alignment>, IAlignmentService
{
public AlignmentService(IMapper mapper, IRepository<Alignment> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.BackgroundViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class BackgroundServices : ServiceBase<BackgroundViewModel, Background>, IBackgroundService
{
public BackgroundServices(IMapper mapper, IRepository<Background> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,20 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.BiographyViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
namespace SessionCompanion.Services.Services
{
public class BiographyService : ServiceBase<BiographyViewModel, Biography>, IBiographyService
{
public BiographyService(IMapper mapper, IRepository<Biography> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,25 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.CharacterViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.EntityFrameworkCore;
using AutoMapper.QueryableExtensions;
using System.IO;
using Newtonsoft.Json.Linq;
namespace SessionCompanion.Services.Services
{
public class CharacterService : ServiceBase<CharacterViewModel, Character>, ICharacterService
{
public CharacterService(IMapper mapper, IRepository<Character> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.CharismaViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class CharismaService : ServiceBase<CharismaViewModel, Charisma>, ICharismaService
{
public CharismaService(IMapper mapper, IRepository<Charisma> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,20 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ClassViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Services
{
public class ClassService : ServiceBase<ClassViewModel, Class>, IClassService
{
public ClassService(IMapper mapper, IRepository<Class> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.ConstitutionViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class ConstitutionService : ServiceBase<ConstitutionViewModel, Constitution>, IConstitutionService
{
public ConstitutionService(IMapper mapper, IRepository<Constitution> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.DexterityViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class DexterityService : ServiceBase<DexterityViewModel, Dexterity>, IDexterityService
{
public DexterityService(IMapper mapper, IRepository<Dexterity> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.IntelligenceViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class IntelligenceService : ServiceBase<IntelligenceViewModel, Intelligence>, IIntelligenceService
{
public IntelligenceService(IMapper mapper, IRepository<Intelligence> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.RaceViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class RaceService : ServiceBase<RaceViewModel, Race>, IRaceService
{
public RaceService(IMapper mapper, IRepository<Race> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,21 @@
using AutoMapper;
using Microsoft.EntityFrameworkCore;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.StatisticsViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SessionCompanion.Services.Services
{
public class StatisticsService : ServiceBase<StatisticsViewModel, Statistics>, IStatisticsService
{
public StatisticsService(IMapper mapper, IRepository<Statistics> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.StrengthViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class StrengthService : ServiceBase<StrengthViewModel, Strength>, IStrengthService
{
public StrengthService(IMapper mapper, IRepository<Strength> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,27 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.UserViewModels;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace SessionCompanion.Services.Services
{
public class UserService : ServiceBase<UserViewModel, User>, IUserService
{
public UserService(IMapper mapper, IRepository<User> repository) : base(mapper, repository)
{ }
public async Task<UserViewModel> SearchUserByUsername(string userName)
{
var User = await Repository.Get(u => u.Username.Equals(userName)).FirstOrDefaultAsync();
return Mapper.Map<UserViewModel>(User);
}
}
}

View File

@ -0,0 +1,18 @@
using AutoMapper;
using SessionCompanion.Database.Repositories.Base;
using SessionCompanion.Database.Tables;
using SessionCompanion.Services.Base;
using SessionCompanion.Services.Interfaces;
using SessionCompanion.ViewModels.WisdomViewModels;
using System;
using System.Collections.Generic;
using System.Text;
namespace SessionCompanion.Services.Services
{
public class WisdomService : ServiceBase<WisdomViewModel, Wisdom>, IWisdomService
{
public WisdomService(IMapper mapper, IRepository<Wisdom> repository) : base(mapper, repository)
{ }
}
}

View File

@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AutoMapper" Version="10.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SessionCompanion.Database\SessionCompanion.Database.csproj" />
<ProjectReference Include="..\SessionCompanion.ViewModels\SessionCompanion.ViewModels.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,10 @@
namespace SessionCompanion.ViewModels.AlignmentViewModels
{
public class AlignmentViewModel
{
/// <summary>
/// Identyfikator przynależności postaci
/// </summary>
public int Id { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using System.Text.Json;
namespace SessionCompanion.ViewModels.ApiResponses
{
public class ErrorResponse
{
/// <summary>
/// Kod błędu
/// </summary>
public int StatusCode { get; set; }
/// <summary>
/// Wiadomość błędu do pokazania
/// </summary>
public string Message { get; set; }
public override string ToString()
{
return JsonSerializer.Serialize(this);
}
}
}

View File

@ -0,0 +1,28 @@
namespace SessionCompanion.ViewModels.ApiResponses
{
/// <summary>
/// Wiadomość mówiąca o poprawnym wykonaniu zadania
/// </summary>
public class SuccessResponse
{
/// <summary>
/// Konstruktor obiektu
/// </summary>
/// <param name="message"> Wiadomość dotycząca operacji </param>
public SuccessResponse(string message)
{
this.SuccessCode = 200;
this.SuccessMessage = message;
}
/// <summary>
/// Kod odpowiedzi, domyślnie nadawany jest 200
/// </summary>
public int SuccessCode { get; set; }
/// <summary>
/// Wiadomość dotycząca wykoanania operacji
/// </summary>
public string SuccessMessage { get; set; }
}
}

View File

@ -0,0 +1,10 @@
namespace SessionCompanion.ViewModels.BackgroundViewModels
{
public class BackgroundViewModel
{
/// <summary>
/// Identyfikator przeszłości postaci
/// </summary>
public int Id { get; set; }
}
}

View File

@ -0,0 +1,40 @@
namespace SessionCompanion.ViewModels.BiographyViewModels
{
public class BiographyViewModel
{
/// <summary>
/// Identyfikator biografii postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Identyfikator postaci
/// </summary>
public int CharacterId { get; set; }
/// <summary>
/// Nazwa postaci
/// </summary>
public string Name { get; set; }
/// <summary>
/// Identyfikator klasy postaci
/// </summary>
public int ClassId { get; set; }
/// <summary>
/// Identyfikator przynależności postaci
/// </summary>
public int AlignmentId { get; set; }
/// <summary>
/// Identyfikator przeszłości postaci
/// </summary>
public int BackgroundId { get; set; }
/// <summary>
/// Płeć postaci
/// </summary>
public string Sex { get; set; }
}
}

View File

@ -0,0 +1,25 @@
namespace SessionCompanion.ViewModels.CharacterViewModels
{
public class CharacterBasicStatsViewModel
{
/// <summary>
/// Identyfikator postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Nazwa postaci
/// </summary>
public string Name { get; set; }
/// <summary>
/// Poziom postaci
/// </summary>
public int Level { get; set; }
/// <summary>
/// Aktualna ilość życia postaci
/// </summary>
public int CurrentHealthPoints { get; set; }
}
}

View File

@ -0,0 +1,30 @@
namespace SessionCompanion.ViewModels.CharacterViewModels
{
public class CharacterForLoginViewModel
{
/// <summary>
/// Identyfikator postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Id użytkownika do którego przypisana jest postać
/// </summary>
public int UserId { get; set; }
/// <summary>
/// Nazwa postaci
/// </summary>
public string Name { get; set; }
/// <summary>
/// Nazwa klasy postaci
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// Poziom postaci
/// </summary>
public int Level { get; set; }
}
}

View File

@ -0,0 +1,15 @@
namespace SessionCompanion.ViewModels.CharacterViewModels
{
public class CharacterViewModel
{
/// <summary>
/// Identyfikator postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Id użytkownika do którego przypisana jest postać
/// </summary>
public int UserId { get; set; }
}
}

View File

@ -0,0 +1,75 @@
namespace SessionCompanion.ViewModels.CharismaViewModels
{
public class CharismaViewModel
{
/// <summary>
/// Identyfikator charyzmy postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Identyfikator postaci
/// </summary>
public int CharacterId { get; set; }
/// <summary>
/// Wartość charyzmy
/// </summary>
public int Value { get; set; }
/// <summary>
/// Modyfikator rzutów
/// </summary>
public int Modification { get; set; }
/// <summary>
/// Modyfikator rzutów obronnych
/// </summary>
public int SavingThrows { get; set; }
/// <summary>
/// Czy postać posiada biegłość w charyźmie
/// </summary>
public bool CanSaveThrows { get; set; }
/// <summary>
/// Wartość umiejętności oszustwa
/// </summary>
public int Deception { get; set; }
/// <summary>
/// Czy postać posiada biegłość w oszustwie
/// </summary>
public bool CanDeception { get; set; }
/// <summary>
/// Wartość umiejętności zastraszania
/// </summary>
public int Intimidation { get; set; }
/// <summary>
/// Czy postać posiada biegłość w zastraszaniu
/// </summary>
public bool CanIntimidation { get; set; }
/// <summary>
/// Wartość umiejętności występowania
/// </summary>
public int Performance { get; set; }
/// <summary>
/// Czy postać posiada biegłość w występowaniu
/// </summary>
public bool CanPerformance { get; set; }
/// <summary>
/// Wartość umiejętności perswazji
/// </summary>
public int Persuasion { get; set; }
/// <summary>
/// Czy postać posiada biegłość w perswazji
/// </summary>
public bool CanPersuasion { get; set; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace SessionCompanion.ViewModels.ClassViewModels
{
public class ClassViewModel
{
/// <summary>
/// Identyfikator klasy postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Nazwa klasy
/// </summary>
public string Name { get; set; }
}
}

View File

@ -0,0 +1,35 @@
namespace SessionCompanion.ViewModels.ConstitutionViewModels
{
public class ConstitutionViewModel
{
/// <summary>
/// Identyfikator kondycji postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Identyfikator postaci
/// </summary>
public int CharacterId { get; set; }
/// <summary>
/// Wartość kondycji
/// </summary>
public int Value { get; set; }
/// <summary>
/// Modyfikator rzutów
/// </summary>
public int Modification { get; set; }
/// <summary>
/// Modyfikator rzutów obronnych
/// </summary>
public int SavingThrows { get; set; }
/// <summary>
/// Czy postać posiada biegłość w kondycji
/// </summary>
public bool CanSaveThrows { get; set; }
}
}

View File

@ -0,0 +1,65 @@
namespace SessionCompanion.ViewModels.DexterityViewModels
{
public class DexterityViewModel
{
/// <summary>
/// Identyfikator zręczności postaci
/// </summary>
public int Id { get; set; }
/// <summary>
/// Identyfikator postaci
/// </summary>
public int CharacterId { get; set; }
/// <summary>
/// Wartość zręczności
/// </summary>
public int Value { get; set; }
/// <summary>
/// Modyfikator rzutów
/// </summary>
public int Modification { get; set; }
/// <summary>
/// Modyfikator rzutów obronnych
/// </summary>
public int SavingThrows { get; set; }
/// <summary>
/// Czy postać posiada biegłość w zręczności
/// </summary>
public bool CanSaveThrows { get; set; }
/// <summary>
/// Wartość umiejętności akrobatyki
/// </summary>
public int Acrobatics { get; set; }
/// <summary>
/// Czy postać posiada biegłość w akrobatyce
/// </summary>
public bool CanAcrobatics { get; set; }
/// <summary>
/// Wartość umiejętności zwinnych dłoni
/// </summary>
public int SleightOfHand { get; set; }
/// <summary>
/// Czy postać posiada biegłość w zwinnych dłoniach
/// </summary>
public bool CanSleightOfHand { get; set; }
/// <summary>
/// Wartość umiejętności skradania się
/// </summary>
public int Stealth { get; set; }
/// <summary>
/// Czy postać posiada biegłość w skradaniu się
/// </summary>
public bool CanStealth { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show More