diff --git a/DataDomain/Address.cs b/DataDomain/Address.cs
new file mode 100644
index 0000000..72c3865
--- /dev/null
+++ b/DataDomain/Address.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class Address
+ {
+ public int Id { get; set; }
+ public string Street { get; set; }
+ public string Street2 { get; set; }
+ public int Zipcode { get; set; }
+ public string Destination { get; set; }
+ public string Nation { get; set; }
+ }
+}
diff --git a/DataDomain/BackupRegister.cs b/DataDomain/BackupRegister.cs
new file mode 100644
index 0000000..1b476b7
--- /dev/null
+++ b/DataDomain/BackupRegister.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class BackupRegister
+ {
+ public int Id { get; set; }
+ public DateTime BackedUp { get; set; }
+ public string DbName { get; set; }
+ public string BackupDbName { get; set; }
+ public string BackupPath { get; set; }
+ }
+}
diff --git a/DataDomain/DataDomain.csproj b/DataDomain/DataDomain.csproj
new file mode 100644
index 0000000..f208d30
--- /dev/null
+++ b/DataDomain/DataDomain.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net5.0
+
+
+
diff --git a/DataDomain/DiTraderStockRow.cs b/DataDomain/DiTraderStockRow.cs
new file mode 100644
index 0000000..fbc48bb
--- /dev/null
+++ b/DataDomain/DiTraderStockRow.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class DiTraderStockRow
+ {
+ public string StockName { get; set; }
+ public decimal ProcChange { get; set; }
+ public decimal RealChange { get; set; }
+ public decimal BuyPrice { get; set; }
+ public decimal SellPrice { get; set; }
+ public decimal LatestPrice { get; set; }
+ public decimal HighestPrice { get; set; }
+ public decimal LowestPrice { get; set; }
+ public long Volume { get; set; }
+ public TimeSpan TimeOfDay { get; set; }
+ }
+}
diff --git a/DataDomain/Person.cs b/DataDomain/Person.cs
new file mode 100644
index 0000000..f291288
--- /dev/null
+++ b/DataDomain/Person.cs
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class Person
+ {
+ public int Id { get; set; }
+ public string FirstName { get; set; }
+ public string LastName { get; set; }
+ public string NickName { get; set; }
+ public String Born { get; set; }
+ public string Comments { get; set; }
+ public int HomeAddress { get; set; }
+ public int InvoiceAddress { get; set; }
+ public int ClearingNo { get; set; }
+ public long AccountNo { get; set; }
+ }
+}
diff --git a/DataDomain/PersonStock.cs b/DataDomain/PersonStock.cs
new file mode 100644
index 0000000..dc646ba
--- /dev/null
+++ b/DataDomain/PersonStock.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class PersonStock
+ {
+ public int Id { get; set; }
+ public int PersonId { get; set; }
+ public int StockId { get; set; }
+ public string Comment { get; set; }
+ }
+}
diff --git a/DataDomain/StockMember.cs b/DataDomain/StockMember.cs
new file mode 100644
index 0000000..f32d888
--- /dev/null
+++ b/DataDomain/StockMember.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DataDomain
+{
+ public class StockMember
+ {
+ public int Id { get; set; }
+ public string StockId { get; set; }
+ public string StockExtId { get; set; }
+ public decimal BuyValue { get; set; }
+ public DateTime BuyDate { get; set; }
+ public decimal ActValue { get; set; }
+ public DateTime? ActDate { get; set; }
+ public long ActAmount { get; set; }
+ public decimal? SoldValue { get; set; }
+ public DateTime? SoldDate { get; set; }
+ // public string PostId { get; set; }
+ public string Comment { get; set; }
+ public long PostAmount { get; set; }
+
+ }
+}
diff --git a/DatamodelLibrary/DatamodelLibrary.csproj b/DatamodelLibrary/DatamodelLibrary.csproj
new file mode 100644
index 0000000..ce8d401
--- /dev/null
+++ b/DatamodelLibrary/DatamodelLibrary.csproj
@@ -0,0 +1,23 @@
+
+
+
+ net5.0
+
+
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DatamodelLibrary/Migrations/20210301205458_initial.Designer.cs b/DatamodelLibrary/Migrations/20210301205458_initial.Designer.cs
new file mode 100644
index 0000000..e0dcfeb
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210301205458_initial.Designer.cs
@@ -0,0 +1,90 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210301205458_initial")]
+ partial class initial
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210301205458_initial.cs b/DatamodelLibrary/Migrations/20210301205458_initial.cs
new file mode 100644
index 0000000..69e9559
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210301205458_initial.cs
@@ -0,0 +1,59 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class initial : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Persons",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ FirstName = table.Column(type: "TEXT", nullable: true),
+ LastName = table.Column(type: "TEXT", nullable: true),
+ NickName = table.Column(type: "TEXT", nullable: true),
+ Born = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Persons", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Stocks",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ StockId = table.Column(type: "TEXT", nullable: true),
+ StockExtId = table.Column(type: "TEXT", nullable: true),
+ BuyValue = table.Column(type: "TEXT", nullable: false),
+ BuyDate = table.Column(type: "TEXT", nullable: false),
+ ActValue = table.Column(type: "TEXT", nullable: false),
+ ActDate = table.Column(type: "TEXT", nullable: true),
+ ActAmount = table.Column(type: "INTEGER", nullable: false),
+ SoldValue = table.Column(type: "TEXT", nullable: true),
+ SoldDate = table.Column(type: "TEXT", nullable: true),
+ Comment = table.Column(type: "TEXT", nullable: true),
+ PostAmount = table.Column(type: "INTEGER", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Stocks", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Persons");
+
+ migrationBuilder.DropTable(
+ name: "Stocks");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210306151633_completion_person_address.Designer.cs b/DatamodelLibrary/Migrations/20210306151633_completion_person_address.Designer.cs
new file mode 100644
index 0000000..5192534
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210306151633_completion_person_address.Designer.cs
@@ -0,0 +1,125 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210306151633_completion_person_address")]
+ partial class completion_person_address
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Gata")
+ .HasColumnType("TEXT");
+
+ b.Property("Gata2")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("PostNr")
+ .HasColumnType("INTEGER");
+
+ b.Property("PostOrt")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210306151633_completion_person_address.cs b/DatamodelLibrary/Migrations/20210306151633_completion_person_address.cs
new file mode 100644
index 0000000..2078fb3
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210306151633_completion_person_address.cs
@@ -0,0 +1,65 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class completion_person_address : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.AddColumn(
+ name: "Comments",
+ table: "Persons",
+ type: "TEXT",
+ nullable: true);
+
+ migrationBuilder.AddColumn(
+ name: "HomeAddress",
+ table: "Persons",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.AddColumn(
+ name: "InvoiceAddress",
+ table: "Persons",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+
+ migrationBuilder.CreateTable(
+ name: "Addresses",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Gata = table.Column(type: "TEXT", nullable: true),
+ Gata2 = table.Column(type: "TEXT", nullable: true),
+ PostNr = table.Column(type: "INTEGER", nullable: false),
+ PostOrt = table.Column(type: "TEXT", nullable: true),
+ Nation = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Addresses", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "Addresses");
+
+ migrationBuilder.DropColumn(
+ name: "Comments",
+ table: "Persons");
+
+ migrationBuilder.DropColumn(
+ name: "HomeAddress",
+ table: "Persons");
+
+ migrationBuilder.DropColumn(
+ name: "InvoiceAddress",
+ table: "Persons");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.Designer.cs b/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.Designer.cs
new file mode 100644
index 0000000..963374f
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.Designer.cs
@@ -0,0 +1,145 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210307074530_completion_person_stock")]
+ partial class completion_person_stock
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Gata")
+ .HasColumnType("TEXT");
+
+ b.Property("Gata2")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("PostNr")
+ .HasColumnType("INTEGER");
+
+ b.Property("PostOrt")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.PersonStock", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PersonId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StockId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("PersonStocks");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.cs b/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.cs
new file mode 100644
index 0000000..a15cc94
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210307074530_completion_person_stock.cs
@@ -0,0 +1,31 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class completion_person_stock : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "PersonStocks",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ PersonId = table.Column(type: "INTEGER", nullable: false),
+ StockId = table.Column(type: "INTEGER", nullable: false),
+ Comment = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_PersonStocks", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "PersonStocks");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.Designer.cs b/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.Designer.cs
new file mode 100644
index 0000000..352329a
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.Designer.cs
@@ -0,0 +1,151 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210307212939_ChangedFormat_Person_Address")]
+ partial class ChangedFormat_Person_Address
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Destination")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("Street")
+ .HasColumnType("TEXT");
+
+ b.Property("Street2")
+ .HasColumnType("TEXT");
+
+ b.Property("Zipcode")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccountNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("ClearingNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.PersonStock", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PersonId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StockId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("PersonStocks");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.cs b/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.cs
new file mode 100644
index 0000000..949c9ca
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210307212939_ChangedFormat_Person_Address.cs
@@ -0,0 +1,75 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class ChangedFormat_Person_Address : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.RenameColumn(
+ name: "PostOrt",
+ table: "Addresses",
+ newName: "Street2");
+
+ migrationBuilder.RenameColumn(
+ name: "PostNr",
+ table: "Addresses",
+ newName: "Zipcode");
+
+ migrationBuilder.RenameColumn(
+ name: "Gata2",
+ table: "Addresses",
+ newName: "Street");
+
+ migrationBuilder.RenameColumn(
+ name: "Gata",
+ table: "Addresses",
+ newName: "Destination");
+
+ migrationBuilder.AddColumn(
+ name: "AccountNo",
+ table: "Persons",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0L);
+
+ migrationBuilder.AddColumn(
+ name: "ClearingNo",
+ table: "Persons",
+ type: "INTEGER",
+ nullable: false,
+ defaultValue: 0);
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropColumn(
+ name: "AccountNo",
+ table: "Persons");
+
+ migrationBuilder.DropColumn(
+ name: "ClearingNo",
+ table: "Persons");
+
+ migrationBuilder.RenameColumn(
+ name: "Zipcode",
+ table: "Addresses",
+ newName: "PostNr");
+
+ migrationBuilder.RenameColumn(
+ name: "Street2",
+ table: "Addresses",
+ newName: "PostOrt");
+
+ migrationBuilder.RenameColumn(
+ name: "Street",
+ table: "Addresses",
+ newName: "Gata2");
+
+ migrationBuilder.RenameColumn(
+ name: "Destination",
+ table: "Addresses",
+ newName: "Gata");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs b/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs
new file mode 100644
index 0000000..277cad6
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210316200448_backupregister.Designer.cs
@@ -0,0 +1,174 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ [Migration("20210316200448_backupregister")]
+ partial class backupregister
+ {
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Destination")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("Street")
+ .HasColumnType("TEXT");
+
+ b.Property("Street2")
+ .HasColumnType("TEXT");
+
+ b.Property("Zipcode")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.BackupRegister", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BackedUp")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupDbName")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupPath")
+ .HasColumnType("TEXT");
+
+ b.Property("DbName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BackupRegings");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccountNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("ClearingNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.PersonStock", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PersonId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StockId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("PersonStocks");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/20210316200448_backupregister.cs b/DatamodelLibrary/Migrations/20210316200448_backupregister.cs
new file mode 100644
index 0000000..4843482
--- /dev/null
+++ b/DatamodelLibrary/Migrations/20210316200448_backupregister.cs
@@ -0,0 +1,33 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace DatamodelLibrary.Migrations
+{
+ public partial class backupregister : Migration
+ {
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "BackupRegings",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ BackedUp = table.Column(type: "TEXT", nullable: false),
+ DbName = table.Column(type: "TEXT", nullable: true),
+ BackupDbName = table.Column(type: "TEXT", nullable: true),
+ BackupPath = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_BackupRegings", x => x.Id);
+ });
+ }
+
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "BackupRegings");
+ }
+ }
+}
diff --git a/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs b/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
new file mode 100644
index 0000000..0b733a7
--- /dev/null
+++ b/DatamodelLibrary/Migrations/StockContextModelSnapshot.cs
@@ -0,0 +1,172 @@
+//
+using System;
+using DatamodelLibrary;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+
+namespace DatamodelLibrary.Migrations
+{
+ [DbContext(typeof(StockContext))]
+ partial class StockContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder
+ .HasAnnotation("ProductVersion", "5.0.3");
+
+ modelBuilder.Entity("DataDomain.Address", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Destination")
+ .HasColumnType("TEXT");
+
+ b.Property("Nation")
+ .HasColumnType("TEXT");
+
+ b.Property("Street")
+ .HasColumnType("TEXT");
+
+ b.Property("Street2")
+ .HasColumnType("TEXT");
+
+ b.Property("Zipcode")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("Addresses");
+ });
+
+ modelBuilder.Entity("DataDomain.BackupRegister", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("BackedUp")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupDbName")
+ .HasColumnType("TEXT");
+
+ b.Property("BackupPath")
+ .HasColumnType("TEXT");
+
+ b.Property("DbName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("BackupRegings");
+ });
+
+ modelBuilder.Entity("DataDomain.Person", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AccountNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Born")
+ .HasColumnType("TEXT");
+
+ b.Property("ClearingNo")
+ .HasColumnType("INTEGER");
+
+ b.Property("Comments")
+ .HasColumnType("TEXT");
+
+ b.Property("FirstName")
+ .HasColumnType("TEXT");
+
+ b.Property("HomeAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("InvoiceAddress")
+ .HasColumnType("INTEGER");
+
+ b.Property("LastName")
+ .HasColumnType("TEXT");
+
+ b.Property("NickName")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Persons");
+ });
+
+ modelBuilder.Entity("DataDomain.PersonStock", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PersonId")
+ .HasColumnType("INTEGER");
+
+ b.Property("StockId")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.ToTable("PersonStocks");
+ });
+
+ modelBuilder.Entity("DataDomain.StockMember", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("ActAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("ActDate")
+ .HasColumnType("TEXT");
+
+ b.Property("ActValue")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyDate")
+ .HasColumnType("TEXT");
+
+ b.Property("BuyValue")
+ .HasColumnType("TEXT");
+
+ b.Property("Comment")
+ .HasColumnType("TEXT");
+
+ b.Property("PostAmount")
+ .HasColumnType("INTEGER");
+
+ b.Property("SoldDate")
+ .HasColumnType("TEXT");
+
+ b.Property("SoldValue")
+ .HasColumnType("TEXT");
+
+ b.Property("StockExtId")
+ .HasColumnType("TEXT");
+
+ b.Property("StockId")
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Stocks");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/DatamodelLibrary/StockContext.cs b/DatamodelLibrary/StockContext.cs
new file mode 100644
index 0000000..6bce6ae
--- /dev/null
+++ b/DatamodelLibrary/StockContext.cs
@@ -0,0 +1,22 @@
+using DataDomain;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DatamodelLibrary
+{
+ public class StockContext : DbContext
+ {
+ public DbSet Stocks { get; set; }
+ public DbSet Persons { get; set; }
+ public DbSet Addresses { get; set; }
+ public DbSet PersonStocks { get; set; }
+ public DbSet BackupRegings { get; set; }
+
+ protected override void OnConfiguring(DbContextOptionsBuilder options)
+ => options.UseSqlite("Data Source=Stocks.db");
+ }
+}
diff --git a/Helpers/ComboboxItem.cs b/Helpers/ComboboxItem.cs
new file mode 100644
index 0000000..f2f8442
--- /dev/null
+++ b/Helpers/ComboboxItem.cs
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Helpers
+{
+ public class ComboboxItem
+ {
+ private readonly string _display;
+ private readonly int _hidden;
+
+ public ComboboxItem(string display,int hidden)
+ {
+ _display = display;
+ _hidden = hidden;
+ }
+ public int HiddenValue
+ {
+ get
+ {
+ return _hidden;
+ }
+ }
+
+ public override string ToString()
+ {
+ return _display;
+ }
+ }
+}
diff --git a/Helpers/Helpers.csproj b/Helpers/Helpers.csproj
new file mode 100644
index 0000000..f208d30
--- /dev/null
+++ b/Helpers/Helpers.csproj
@@ -0,0 +1,7 @@
+
+
+
+ net5.0
+
+
+
diff --git a/Helpers/StringExtensions.cs b/Helpers/StringExtensions.cs
new file mode 100644
index 0000000..b8978fc
--- /dev/null
+++ b/Helpers/StringExtensions.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Globalization;
+
+namespace Helpers
+{
+ public static class StringExtensions
+ {
+ public static bool IsNumeric(this string s)
+ {
+ return float.TryParse(s, NumberStyles.Float | NumberStyles.Integer, CultureInfo.CurrentUICulture, out _);
+ }
+ }
+}
diff --git a/SqliteBackups/BackupRoutines.cs b/SqliteBackups/BackupRoutines.cs
new file mode 100644
index 0000000..3e7dbc8
--- /dev/null
+++ b/SqliteBackups/BackupRoutines.cs
@@ -0,0 +1,22 @@
+using SqliteBackups.Interfaces;
+using System;
+using System.Collections.Generic;
+using System.Data.SQLite;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SqliteBackups
+{
+ public class BackupRoutines : IBackupRoutines
+ {
+ public void BackupSqliteDb(string fromDb, string toDb)
+ {
+ using var source = new SQLiteConnection($"Data Source={fromDb}; Version=3;");
+ using var destination = new SQLiteConnection($"Data Source={toDb}; Version=3;");
+ source.Open();
+ destination.Open();
+ source.BackupDatabase(destination, "main", "main", -1, null, 0);
+ }
+ }
+}
diff --git a/SqliteBackups/Interfaces/IBackupRoutines.cs b/SqliteBackups/Interfaces/IBackupRoutines.cs
new file mode 100644
index 0000000..ca94ef1
--- /dev/null
+++ b/SqliteBackups/Interfaces/IBackupRoutines.cs
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SqliteBackups.Interfaces
+{
+ public interface IBackupRoutines
+ {
+ void BackupSqliteDb(string fromDb, string toDb);
+ }
+}
diff --git a/SqliteBackups/SqliteBackups.csproj b/SqliteBackups/SqliteBackups.csproj
new file mode 100644
index 0000000..596e5c1
--- /dev/null
+++ b/SqliteBackups/SqliteBackups.csproj
@@ -0,0 +1,11 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
diff --git a/StockBL.Interface/IPersonStockFacade.cs b/StockBL.Interface/IPersonStockFacade.cs
new file mode 100644
index 0000000..a8462f8
--- /dev/null
+++ b/StockBL.Interface/IPersonStockFacade.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using DataDomain;
+
+namespace StockBL.Interface
+{
+ public interface IPersonStockFacade
+ {
+ IEnumerable GetAllSharesConnectedTo(int personId);
+ System.Collections.Generic.IEnumerable GetUnconnectedShares();
+ }
+}
diff --git a/StockBL.Interface/StockBL.Interface.csproj b/StockBL.Interface/StockBL.Interface.csproj
new file mode 100644
index 0000000..a3f6e2a
--- /dev/null
+++ b/StockBL.Interface/StockBL.Interface.csproj
@@ -0,0 +1,11 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
diff --git a/StockBL/PersonStockFacade.cs b/StockBL/PersonStockFacade.cs
new file mode 100644
index 0000000..4bb078e
--- /dev/null
+++ b/StockBL/PersonStockFacade.cs
@@ -0,0 +1,47 @@
+using DataDomain;
+using StockBL.Interface;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+
+namespace StockBL
+{
+ public class PersonStockFacade : IPersonStockFacade
+ {
+ private readonly IStockPersonConnect _stockPersonConnect;
+ private readonly IStockRepository _stockRepository;
+
+ public PersonStockFacade(IStockPersonConnect stockPersonConnect, IStockRepository stockRepository)
+ {
+ _stockPersonConnect = stockPersonConnect;
+ _stockRepository = stockRepository;
+ }
+
+ public IEnumerable GetUnconnectedShares()
+ {
+ var stockList = _stockRepository.GetAllStocks();
+ var connectList = _stockPersonConnect.GetAllConnectedStocks();
+
+
+ var stcList = (from st in stockList
+ where connectList.Any(co => st.Id == co.StockId)
+ select st).ToList();
+
+ var sList = stockList.Except(stcList).ToList();
+
+ return sList;
+ }
+
+ public IEnumerable GetAllSharesConnectedTo(int personId)
+ {
+ var personConnections = _stockPersonConnect.GetAllConnectionsByPersId(personId);
+ var stockList = _stockRepository.GetAllStocks();
+
+ var stcList = (from st in stockList
+ where personConnections.Any(pc => st.Id == pc.StockId)
+ select st).ToList();
+ return stcList;
+ }
+ }
+}
diff --git a/StockBL/StockBL.csproj b/StockBL/StockBL.csproj
new file mode 100644
index 0000000..087b712
--- /dev/null
+++ b/StockBL/StockBL.csproj
@@ -0,0 +1,14 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
diff --git a/StockDAL/AddressRepository.cs b/StockDAL/AddressRepository.cs
new file mode 100644
index 0000000..8d71f46
--- /dev/null
+++ b/StockDAL/AddressRepository.cs
@@ -0,0 +1,55 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class AddressRepository : IAddressRepository
+ {
+ public Address GetAddressById(int AddressId)
+ {
+ using var context = new StockContext();
+ var entity = (from adr in context.Addresses
+ where adr.Id == AddressId
+ select adr).FirstOrDefault();
+ return entity;
+ }
+
+ public Address SaveAddress(Address address)
+ {
+ using var context = new StockContext();
+ var entity = (from adr in context.Addresses
+ where adr.Id == address.Id
+ select adr).FirstOrDefault();
+
+ if (entity == null)
+ {
+ entity = new Address
+ {
+ Street = address.Street,
+ Street2 = address.Street2,
+ Zipcode = address.Zipcode,
+ Destination = address.Destination,
+ Nation = address.Nation
+ };
+ context.Addresses.Add(entity);
+ }
+ else
+ {
+ entity.Street = address.Street;
+ entity.Street2 = address.Street2;
+ entity.Zipcode = address.Zipcode;
+ entity.Destination = address.Destination;
+ entity.Nation = address.Nation;
+ }
+
+ context.SaveChanges();
+ return entity;
+ }
+ }
+}
diff --git a/StockDAL/BackupRepository.cs b/StockDAL/BackupRepository.cs
new file mode 100644
index 0000000..50e44c7
--- /dev/null
+++ b/StockDAL/BackupRepository.cs
@@ -0,0 +1,61 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class BackupRepository : IBackupRepository
+ {
+ public BackupRegister SaveBackupReging(BackupRegister backupRegister)
+ {
+ using var context = new StockContext();
+ var entity = (from brr in context.BackupRegings
+ where brr.Id == backupRegister.Id
+ select brr).FirstOrDefault();
+ if (entity == null)
+ {
+ entity = new BackupRegister
+ {
+ BackedUp = DateTime.Now,
+ DbName = "Stocks.db",
+ BackupDbName = backupRegister.BackupDbName,
+ BackupPath = backupRegister.BackupPath
+ };
+ context.BackupRegings.Add(entity);
+ }
+ else
+ {
+ entity.BackedUp = backupRegister.BackedUp;
+ entity.DbName = backupRegister.DbName;
+ entity.BackupDbName = backupRegister.BackupDbName;
+ entity.BackupPath = backupRegister.BackupPath;
+ }
+
+ context.SaveChanges();
+ return entity;
+ }
+
+
+ public BackupRegister GetBackupRegisterById(int brId)
+ {
+ using var context = new StockContext();
+ var entity = (from br in context.BackupRegings
+ where br.Id == brId
+ select br).FirstOrDefault();
+ return entity;
+ }
+
+
+ public IEnumerable GetAllBackupRegisters()
+ {
+ using var context = new StockContext();
+ var entities = context.BackupRegings;
+ return entities.ToList();
+ }
+ }
+}
diff --git a/StockDAL/PersonRepository.cs b/StockDAL/PersonRepository.cs
new file mode 100644
index 0000000..3ada103
--- /dev/null
+++ b/StockDAL/PersonRepository.cs
@@ -0,0 +1,75 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class PersonRepository : IPersonRepository
+ {
+ public Person GetPersonById(int personId)
+ {
+ using var context = new StockContext();
+ var entity = (from prs in context.Persons
+ where prs.Id == personId
+ select prs).FirstOrDefault();
+ return entity;
+ }
+
+ public IEnumerable GetAllOwners()
+ {
+ using var context = new StockContext();
+ var output = context.Persons;
+ return output.ToList();
+ }
+
+
+ public Person SavePerson(Person person)
+ {
+ using var context = new StockContext();
+
+ var entity = (from prs in context.Persons
+ where prs.Id == person.Id
+ select prs).FirstOrDefault();
+
+ if (entity == null)
+ {
+ entity = new Person
+ {
+ AccountNo = person.AccountNo,
+ Born = person.Born,
+ ClearingNo = person.ClearingNo,
+ Comments = person.Comments,
+ FirstName = person.FirstName,
+ HomeAddress = person.HomeAddress,
+ InvoiceAddress = person.InvoiceAddress,
+ LastName = person.LastName,
+ NickName = person.NickName
+ };
+ context.Persons.Add(entity);
+ }
+ else
+ {
+ entity.AccountNo = person.AccountNo;
+ entity.Born = person.Born;
+ entity.ClearingNo = person.ClearingNo;
+ entity.Comments = person.Comments;
+ entity.FirstName = person.FirstName;
+ entity.HomeAddress = person.HomeAddress;
+ entity.InvoiceAddress = person.InvoiceAddress;
+ entity.LastName = person.LastName;
+ entity.NickName = person.NickName;
+ }
+
+ context.SaveChanges();
+
+ return entity;
+ }
+ }
+
+
+}
diff --git a/StockDAL/StockDAL.csproj b/StockDAL/StockDAL.csproj
new file mode 100644
index 0000000..dfc2f83
--- /dev/null
+++ b/StockDAL/StockDAL.csproj
@@ -0,0 +1,20 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StockDAL/StockMarketRepository.cs b/StockDAL/StockMarketRepository.cs
new file mode 100644
index 0000000..37d9d76
--- /dev/null
+++ b/StockDAL/StockMarketRepository.cs
@@ -0,0 +1,239 @@
+using Newtonsoft.Json;
+using OpenQA.Selenium;
+using OpenQA.Selenium.Chrome;
+using StockDal.Interface;
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Reflection;
+using System.Diagnostics;
+
+namespace StockDal
+{
+ public class StockMarketRepository : IStockMarketRepository
+ {
+ public Dictionary StockMarketList { get; set; }
+
+ public List DumpObjects { get; set; } = new List();
+ public DiTraderStockRow SaveRow { get; set; }
+ public StringBuilder TextResults { get; set; }
+ public bool ViewBrowser { get; set; }
+
+ public IWebDriver driver;
+
+ public StockMarketRepository()
+ {
+ ViewBrowser = false;
+ }
+
+ private void Find_Data()
+ {
+ TextResults = new StringBuilder();
+ IList searchElements = driver.FindElements(By.TagName("tbody"));
+ foreach (IWebElement i in searchElements)
+ {
+
+ HtmlAgilityPack.HtmlDocument htmlDocument = new HtmlAgilityPack.HtmlDocument();
+ var text = i.GetAttribute("innerHTML");
+ htmlDocument.LoadHtml(text);
+ var inputs = htmlDocument.DocumentNode.Descendants("tr").ToList();
+ foreach (var items in inputs)
+ {
+ HtmlAgilityPack.HtmlDocument htmlDocument1 = new HtmlAgilityPack.HtmlDocument();
+ htmlDocument1.LoadHtml(items.InnerHtml);
+ var tds = htmlDocument1.DocumentNode.Descendants("td").ToList();
+ var appendText = "";
+ var fNr = 0;
+ foreach (var item in tds)
+ {
+ var intext = item.InnerText.Replace("\r\n", "");
+ appendText += appendText.Length == 0 ? intext : " " + intext;
+ if (tds.Count == 10)
+ {
+ AddValueToListRow(fNr++, intext);
+ }
+ }
+ if (!string.IsNullOrEmpty(appendText))
+ {
+ TextResults.Append(appendText + "\r\n");
+ }
+ htmlDocument1 = null;
+ }
+ htmlDocument = null;
+
+ TextResults.Append("\r\n");
+ }
+
+ // var oxe = StockMarketList;
+ }
+
+ private void SaveLogging()
+ {
+ var output = JsonConvert.SerializeObject(DumpObjects, Formatting.Indented);
+ Assembly assem = typeof(StockMarketRepository).Assembly;
+ var programPath = assem.Location.Substring(0, assem.Location.LastIndexOf("\\"));
+ var logPath = new DirectoryInfo(programPath + "\\Loggings");
+ if (!logPath.Exists)
+ {
+ logPath.Create();
+ }
+ File.WriteAllText($"{programPath}\\Loggings\\Log{DateTime.Now.ToShortDateString()}.txt", output);
+ }
+
+ private void AddValueToListRow(int pos, string value)
+ {
+ switch (pos)
+ {
+ case 0:
+ {
+ SaveRow = new DiTraderStockRow();
+ SaveRow.StockName = value;
+ break;
+ }
+ case 1:
+ {
+ SaveRow.ProcChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 2:
+ {
+ SaveRow.RealChange = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 3:
+ {
+ SaveRow.BuyPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 4:
+ {
+ SaveRow.SellPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 5:
+ {
+ SaveRow.LatestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 6:
+ {
+ SaveRow.HighestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 7:
+ {
+ SaveRow.LowestPrice = string.IsNullOrWhiteSpace(value) ? 0 : decimal.Parse(value);
+ break;
+ }
+ case 8:
+ {
+
+ SaveRow.Volume = string.IsNullOrWhiteSpace(value) ? 0 : long.Parse(value.Replace(" ", ""));
+ break;
+ }
+ case 9:
+ {
+ SaveRow.TimeOfDay = value==""?TimeSpan.Parse("00:01"): TimeSpan.Parse(value);
+ //StockMarketList.Add(SaveRow.StockName, SaveRow);
+ try
+ {
+ StockMarketList.Add(SaveRow.StockName, SaveRow);
+ }
+ catch (ArgumentException )
+ {
+ try
+ {
+ StockMarketList.Add(SaveRow.StockName + "-2", SaveRow);
+ }
+ catch (Exception)
+ {
+ DumpObjects.Add(SaveRow);
+ }
+
+ }
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+ private void OpenBrowser(bool burl2 = false)
+ {
+ var driverService = ChromeDriverService.CreateDefaultService();
+ driverService.HideCommandPromptWindow = true;
+
+ if (ViewBrowser)
+ {
+ if (driver == null)
+ {
+ driver = new ChromeDriver(driverService);
+ }
+ }
+ else
+ {
+ if (driver == null)
+ {
+ var options = new ChromeOptions();
+ options.AddArgument("headless");
+ driver = new ChromeDriver(driverService, options);
+ }
+ }
+
+ try
+ {
+ //var url0 = "https://money.cnn.com/data/hotstocks/index.html";
+ var url = "https://trader.di.se/index.php/stocklist/index/2055?list=7126";
+ var url2 = "https://trader.di.se/index.php/stocklist/index/2055?list=7116";
+ //var url1 = "https://www.finansportalen.se/aktiekurser/";
+ driver.Navigate().GoToUrl(burl2 ? url2 : url);
+
+ }
+ catch
+ {
+ throw;
+ }
+
+ }
+
+ public void LoadStockMarketList()
+ {
+ StockMarketList = new Dictionary();
+ DumpObjects = new List();
+ OpenBrowser();
+ Find_Data();
+ OpenBrowser(true);
+ Find_Data();
+ if (DumpObjects.Any())
+ {
+ SaveLogging();
+ }
+ }
+
+
+ public void LoadStockMarketList(bool viewBrowser)
+ {
+ StockMarketList = new Dictionary();
+ ViewBrowser = viewBrowser;
+ OpenBrowser();
+ Find_Data();
+ }
+
+ public void RefreshMarketList()
+ {
+ StockMarketList = new Dictionary();
+ driver.Navigate().Refresh();
+ Find_Data();
+ }
+
+ public void Clean()
+ {
+ driver?.Quit();
+ }
+
+ }
+}
diff --git a/StockDAL/StockPersonConnect.cs b/StockDAL/StockPersonConnect.cs
new file mode 100644
index 0000000..afd9634
--- /dev/null
+++ b/StockDAL/StockPersonConnect.cs
@@ -0,0 +1,72 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class StockPersonConnect : IStockPersonConnect
+ {
+ public IEnumerable GetAllConnectionsByPersId(int personId)
+ {
+ using var context = new StockContext();
+ var connections = (from spc in context.PersonStocks
+ where spc.PersonId == personId
+ select spc).ToList();
+ return connections;
+ }
+
+ public IEnumerable GetAllConnectedStocks()
+ {
+ using var context = new StockContext();
+ var entities = (from spc in context.PersonStocks
+ where spc.PersonId != 0
+ select spc).ToList();
+ return entities;
+ }
+
+ public PersonStock SavePersonStockConnection(PersonStock personStock)
+ {
+ using var context = new StockContext();
+ var entity = (from ps in context.PersonStocks
+ where ps.Id == personStock.Id
+ select ps).FirstOrDefault();
+ if (entity == null)
+ {
+ entity = new PersonStock
+ {
+ PersonId = personStock.PersonId,
+ StockId = personStock.StockId,
+ Comment = personStock.Comment
+ };
+ context.PersonStocks.Add(entity);
+ }
+ else
+ {
+ entity.PersonId = personStock.PersonId;
+ entity.StockId = personStock.StockId;
+ entity.Comment = personStock.Comment;
+ }
+ context.SaveChanges();
+
+ return entity;
+ }
+
+ public void RemoveConnectedShare(PersonStock personStock)
+ {
+ using var context = new StockContext();
+ var entity = (from ps in context.PersonStocks
+ where ps.StockId == personStock.StockId
+ select ps).FirstOrDefault();
+ if (entity != null)
+ {
+ context.PersonStocks.Remove(entity);
+ context.SaveChanges();
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/StockDAL/StockRepository.cs b/StockDAL/StockRepository.cs
new file mode 100644
index 0000000..6d1a292
--- /dev/null
+++ b/StockDAL/StockRepository.cs
@@ -0,0 +1,115 @@
+using DataDomain;
+using DatamodelLibrary;
+using StockDAL.Interface;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL
+{
+ public class StockRepository : IStockRepository
+ {
+ public void SaveStockMember(StockMember stockMember)
+ {
+ using (var context = new StockContext())
+ {
+ var sm = context.Stocks.Add(stockMember);
+ context.SaveChanges();
+ }
+ }
+
+ public void UpdateActualPrice(int id, decimal price)
+ {
+ using var context = new StockContext();
+ var entity = (from stk in context.Stocks
+ where stk.Id == id
+ select stk).FirstOrDefault();
+
+ entity.ActValue = price;
+ entity.ActDate = DateTime.Today;
+
+ context.SaveChanges();
+ }
+
+ public void UpdateActualForSell(int id, int sellAmount, decimal sellPrice, DateTime sellDate)
+ {
+ using var context = new StockContext();
+ var entity = (from stk in context.Stocks
+ where stk.Id == id
+ select stk).FirstOrDefault();
+ var rest = entity.ActAmount - sellAmount;
+ entity.ActAmount = rest < 0 ? 0 : rest;
+ entity.SoldDate = DateTime.Today;
+ entity.SoldValue = sellAmount * sellPrice;
+
+ context.SaveChanges();
+ }
+
+
+ public IEnumerable GetAllStocks()
+ {
+ using var context = new StockContext();
+ var output = context.Stocks;
+ return output.ToList();
+ }
+
+ public IEnumerable GetAllRemainingStocks()
+ {
+ using var context = new StockContext();
+ var output = (from stk in context.Stocks
+ where stk.SoldDate == null || stk.ActAmount > 0
+ select stk).ToList();
+ return output;
+ }
+
+ public void RemoveAllStocks()
+ {
+ using var context = new StockContext();
+ context.Stocks.RemoveRange(GetAllStocks());
+ context.SaveChanges();
+ }
+
+ public void InsertMany(List stockMembers)
+ {
+ using var context = new StockContext();
+ context.Stocks.AddRange(stockMembers);
+ context.SaveChanges();
+ }
+
+ public void RestoreStockMembers(List stockMembers)
+ {
+ using var context = new StockContext();
+ using var transaction = context.Database.BeginTransaction();
+
+ try
+ {
+ var stocksToRemove = context.Stocks;
+ context.Stocks.RemoveRange(stocksToRemove);
+ var insertStocks = stockMembers.Select(o => new StockMember
+ {
+ Id = 0,
+ StockId = o.StockId,
+ StockExtId = o.StockExtId,
+ BuyDate = o.BuyDate,
+ BuyValue = o.BuyValue,
+ ActAmount = o.ActAmount,
+ ActValue = o.ActValue,
+ ActDate = o.ActDate,
+ SoldValue = o.SoldValue,
+ SoldDate = o.SoldDate,
+ Comment = o.Comment,
+ PostAmount = o.PostAmount
+ }).ToList();
+ context.Stocks.AddRange(insertStocks);
+ context.SaveChanges();
+ transaction.Commit();
+ }
+ catch (Exception ex)
+ {
+ throw new InvalidOperationException(ex.Message);
+ }
+ }
+ }
+}
diff --git a/StockDal.Interface/IAddressRepository.cs b/StockDal.Interface/IAddressRepository.cs
new file mode 100644
index 0000000..65e6688
--- /dev/null
+++ b/StockDal.Interface/IAddressRepository.cs
@@ -0,0 +1,15 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IAddressRepository
+ {
+ Address GetAddressById(int AddressId);
+ Address SaveAddress(Address address);
+ }
+}
diff --git a/StockDal.Interface/IBackupRepository.cs b/StockDal.Interface/IBackupRepository.cs
new file mode 100644
index 0000000..90060bb
--- /dev/null
+++ b/StockDal.Interface/IBackupRepository.cs
@@ -0,0 +1,16 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IBackupRepository
+ {
+ IEnumerable GetAllBackupRegisters();
+ BackupRegister GetBackupRegisterById(int brId);
+ BackupRegister SaveBackupReging(BackupRegister backupRegister);
+ }
+}
diff --git a/StockDal.Interface/IPersonRepository.cs b/StockDal.Interface/IPersonRepository.cs
new file mode 100644
index 0000000..ac99c40
--- /dev/null
+++ b/StockDal.Interface/IPersonRepository.cs
@@ -0,0 +1,16 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IPersonRepository
+ {
+ IEnumerable GetAllOwners();
+ Person GetPersonById(int personId);
+ Person SavePerson(Person person);
+ }
+}
diff --git a/StockDal.Interface/IStockMarketRepository.cs b/StockDal.Interface/IStockMarketRepository.cs
new file mode 100644
index 0000000..daf4e60
--- /dev/null
+++ b/StockDal.Interface/IStockMarketRepository.cs
@@ -0,0 +1,20 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDal.Interface
+{
+ public interface IStockMarketRepository
+ {
+ Dictionary StockMarketList { get; set; }
+ bool ViewBrowser { get; set; }
+
+ void Clean();
+ void LoadStockMarketList();
+ void LoadStockMarketList(bool viewBrowser);
+ void RefreshMarketList();
+ }
+}
diff --git a/StockDal.Interface/IStockPersonConnect.cs b/StockDal.Interface/IStockPersonConnect.cs
new file mode 100644
index 0000000..45cb133
--- /dev/null
+++ b/StockDal.Interface/IStockPersonConnect.cs
@@ -0,0 +1,17 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IStockPersonConnect
+ {
+ IEnumerable GetAllConnectedStocks();
+ IEnumerable GetAllConnectionsByPersId(int personId);
+ void RemoveConnectedShare(PersonStock personStock);
+ PersonStock SavePersonStockConnection(PersonStock personStock);
+ }
+}
diff --git a/StockDal.Interface/IStockRepository.cs b/StockDal.Interface/IStockRepository.cs
new file mode 100644
index 0000000..cdb4a88
--- /dev/null
+++ b/StockDal.Interface/IStockRepository.cs
@@ -0,0 +1,21 @@
+using DataDomain;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace StockDAL.Interface
+{
+ public interface IStockRepository
+ {
+ IEnumerable GetAllRemainingStocks();
+ IEnumerable GetAllStocks();
+ void InsertMany(List stockMembers);
+ void RemoveAllStocks();
+ void RestoreStockMembers(List stockMembers);
+ void SaveStockMember(StockMember stockMember);
+ void UpdateActualForSell(int id, int sellAmount, decimal sellPrice, DateTime sellDate);
+ void UpdateActualPrice(int id, decimal price);
+ }
+}
diff --git a/StockDal.Interface/StockDAL.Interface.csproj b/StockDal.Interface/StockDAL.Interface.csproj
new file mode 100644
index 0000000..8229020
--- /dev/null
+++ b/StockDal.Interface/StockDAL.Interface.csproj
@@ -0,0 +1,16 @@
+
+
+
+ net5.0
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/StockInfoCore/Program.cs b/StockInfoCore/Program.cs
new file mode 100644
index 0000000..cb4315a
--- /dev/null
+++ b/StockInfoCore/Program.cs
@@ -0,0 +1,49 @@
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace StockInfoCore
+{
+ static class Program
+ {
+ ///
+ /// The main entry point for the application.
+ ///
+ [STAThread]
+
+ static void Main()
+ {
+ var builder = new HostBuilder()
+ .ConfigureServices((_, services) =>
+ {
+ services.AddDIInfo();
+ });
+
+ var host = builder.Build();
+ using var scope = host.Services.CreateScope();
+
+ try
+ {
+ var services = scope.ServiceProvider;
+
+ Application.SetHighDpiMode(HighDpiMode.SystemAware);
+ Application.EnableVisualStyles();
+ Application.SetCompatibleTextRenderingDefault(false);
+
+ var frm = services.GetRequiredService();
+
+ Application.Run(frm);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"An error has occured: { ex.Message}");
+ }
+
+ }
+
+ }
+}
diff --git a/StockInfoCore/StockInfoCore.csproj b/StockInfoCore/StockInfoCore.csproj
new file mode 100644
index 0000000..c17cd41
--- /dev/null
+++ b/StockInfoCore/StockInfoCore.csproj
@@ -0,0 +1,34 @@
+
+
+
+ WinExe
+ net5.0-windows
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+