Compare commits

..

32 Commits

Author SHA1 Message Date
1e50bd15fa Fixed typo 2020-12-10 16:52:50 +01:00
16721ed210 Need to make sure it works 2020-12-10 16:51:00 +01:00
6e89872ddb Add withEnv, fix typo 2020-12-10 16:43:44 +01:00
8dc1c8c1d7 Add withEnv 2020-12-10 16:40:13 +01:00
e666adf2b4 Check username 2020-12-09 19:35:21 +01:00
7b556ef953 Try different source image 2020-12-09 19:27:21 +01:00
5d3531b2d2 Try to create dir needed 2020-12-09 19:22:40 +01:00
586f0acf7f Try to fix casche problem, fix typo 2020-12-09 19:17:14 +01:00
5f0d2adb00 Try to fix casche problem 2020-12-09 19:14:24 +01:00
eeea4f86d1 Add proper image this time 2020-12-09 19:09:22 +01:00
df3312e788 Try custom image 2020-12-09 19:06:43 +01:00
fabf198f48 Again with my image 2020-12-04 19:31:58 +01:00
f87523cf34 with node installing fix 2020-12-04 19:25:05 +01:00
67d519df5e with node installing 2020-12-04 19:23:20 +01:00
89fa6939ea no node 2020-12-04 19:20:24 +01:00
08e886610e Test both images, different agents 2020-12-04 19:09:40 +01:00
eb25599c9f Test both images 2020-12-04 19:07:31 +01:00
2ed9fa825e Test only node 2020-12-04 19:05:57 +01:00
6df7f174ce Try idea with dockerhub add version 2020-12-04 18:57:55 +01:00
1407e61997 Try idea with dockerhub fix bug 2020-12-04 18:56:37 +01:00
023ae1ff6c Try idea with dockerhub 2020-12-04 18:55:59 +01:00
647736d8f7 Test two docker images 2020-12-04 18:46:53 +01:00
4e240b7506 Test double images 2020-12-04 18:04:15 +01:00
6ce52af934 Add try with new image, only node:12 2020-12-04 17:56:48 +01:00
67e52719f2 Add try with new image fix 2020-12-04 17:53:36 +01:00
04f56e5078 Add try with new image 2020-12-04 17:49:35 +01:00
c9d927aeb9 Test envioment, check env 2020-12-04 14:41:54 +01:00
2cb69eb3b5 Test envioment fix bug 2020-12-04 14:38:48 +01:00
800459a894 test evlioment 2020-12-04 14:37:46 +01:00
2c3dd7f0d2 Try to make it run dotnet 2020-12-03 17:30:56 +01:00
356f0b2ea1 Test new config, fixed bugs 2020-12-03 17:28:14 +01:00
734368df68 Test new config 2020-12-03 17:26:07 +01:00
160 changed files with 319 additions and 7049 deletions

32
Jenkinsfile vendored
View File

@ -1,3 +1,24 @@
//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 {
@ -13,22 +34,15 @@ pipeline {
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') {
stage('Clarify') {
steps {
withEnv(["HOME=${env.WORKSPACE}"]){
sh 'rm -rf .local'
}
sh "echo Dziala"
}
}
}
}

View File

@ -1,36 +0,0 @@
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

@ -1,317 +0,0 @@
// <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

@ -1,248 +0,0 @@
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

@ -1,683 +0,0 @@
// <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

@ -1,251 +0,0 @@
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

@ -1,681 +0,0 @@
// <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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,24 +0,0 @@
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

@ -1,72 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,39 +0,0 @@
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

@ -1,20 +0,0 @@
<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

@ -1,11 +0,0 @@
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

@ -1,11 +0,0 @@
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

@ -1,15 +0,0 @@
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

@ -1,34 +0,0 @@
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

@ -1,23 +0,0 @@
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

@ -1,27 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,19 +0,0 @@
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

@ -1,25 +0,0 @@
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

@ -1,29 +0,0 @@
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

@ -1,12 +0,0 @@
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

@ -1,23 +0,0 @@
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

@ -1,21 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,29 +0,0 @@
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

@ -1,119 +0,0 @@
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

@ -1,184 +0,0 @@
# 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

@ -1,11 +0,0 @@
<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

@ -1,19 +0,0 @@
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

@ -1,73 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,14 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,15 +0,0 @@
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

@ -1,13 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,29 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,17 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,25 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,21 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,27 +0,0 @@
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

@ -1,18 +0,0 @@
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

@ -1,16 +0,0 @@
<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

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

View File

@ -1,22 +0,0 @@
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

@ -1,28 +0,0 @@
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

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

View File

@ -1,40 +0,0 @@
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

@ -1,25 +0,0 @@
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

@ -1,30 +0,0 @@
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

@ -1,15 +0,0 @@
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

@ -1,75 +0,0 @@
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

@ -1,20 +0,0 @@
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

@ -1,35 +0,0 @@
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

@ -1,65 +0,0 @@
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