commit ea9391d6eabe51800b25978b46c581e595651819
Author: Milan Hotovec <silent@students.zcu.cz>
Date:   Sun Apr 25 16:41:48 2021 +0200

    Added registrars
    refs #8555 @2h
    @testFull

diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Comment.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Comment.cs
index 53a4d10..1021865 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Comment.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Comment.cs
@@ -15,7 +15,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
 
         }
 
-        public Comment(DomainUser creator, Goal goal, string text, bool isPrivate)
+        public Comment(DomainUser creator, GoalItem goal, string text, bool isPrivate)
         {
             this.Creator = creator;
             this.CreatorId = creator.UserId;
@@ -28,7 +28,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
         public Guid Id { get; private set; }
         public DomainUser Creator { get; private set; }
         public Guid CreatorId { get; private set; }
-        public Goal Goal { get; private set; }
+        public GoalItem Goal { get; private set; }
         public Guid GoalId { get; private set; }
         public string Text { get; private set; }
         public bool IsPrivate { get; private set; }
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Goal.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Goal.cs
deleted file mode 100644
index 41743e9..0000000
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Goal.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-﻿using Leuze.Core.Domain.Domains;
-using Leuze.Core.Domain.Domains.Users;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Leuze.Modules.Goal.Domain.Domains
-{
-    public class Goal : BaseEntity
-    {
-        private Goal()
-        {
-
-        }
-
-        public Goal(GoalDefinition goalDefinition, DomainUser creator, string name, string description)
-        {
-            this.GoalDefinition = goalDefinition;
-            this.GoalDefinitionId = goalDefinition.Id;
-            this.Creator = creator;
-            this.CreatorId = creator.UserId;
-            this.Name = name;
-            this.Description = description;
-        }
-
-        public Guid Id { get; private set; }
-        public GoalDefinition GoalDefinition { get; private set; }
-        public Guid GoalDefinitionId { get; private set; }
-        public DomainUser Creator { get; private set; }
-        public Guid CreatorId { get; private set; }
-        public string Name { get; private set; }
-        public string Description { get; private set; }
-        public int PercentileUser { get; private set; }
-        public int PercentileFinal { get; private set; }
-    }
-}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
index da78de2..f362681 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalDefinition.cs
@@ -36,5 +36,8 @@ namespace Leuze.Modules.Goal.Domain.Domains
         public DateTime From { get; private set; }
         public DateTime To { get; private set; }
         public decimal Vari { get; private set; }
+
+        private List<GoalItem> _goals { get; set; }
+        public IReadOnlyList<GoalItem> Goals => _goals.AsReadOnly();
     }
 }
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
new file mode 100644
index 0000000..2d2c078
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalItem.cs
@@ -0,0 +1,47 @@
+﻿using Leuze.Core.Domain.Domains;
+using Leuze.Core.Domain.Domains.Users;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Domains
+{
+    public class GoalItem : BaseEntity
+    {
+        private GoalItem()
+        {
+
+        }
+
+        public GoalItem(GoalDefinition goalDefinition, DomainUser creator, string name, string description)
+        {
+            this.GoalDefinition = goalDefinition;
+            this.GoalDefinitionId = goalDefinition.Id;
+            this.Creator = creator;
+            this.CreatorId = creator.UserId;
+            this.Name = name;
+            this.Description = description;
+        }
+
+        public Guid Id { get; private set; }
+        public GoalDefinition GoalDefinition { get; private set; }
+        public Guid GoalDefinitionId { get; private set; }
+        public DomainUser Creator { get; private set; }
+        public Guid CreatorId { get; private set; }
+        public string Name { get; private set; }
+        public string Description { get; private set; }
+        public int PercentileUser { get; private set; }
+        public int PercentileFinal { get; private set; }
+
+        private List<Comment> _comments { get; set; }
+        public IReadOnlyList<Comment> Comments => _comments.AsReadOnly();
+
+        private List<GoalUpdate> _updates { get; set; }
+        public IReadOnlyList<GoalUpdate> Updates => _updates.AsReadOnly();
+
+        private List<Review> _reviews { get; set; }
+        public IReadOnlyList<Review> Reviews => _reviews.AsReadOnly();
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalUpdate.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalUpdate.cs
index c779e8c..ce94a40 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalUpdate.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/GoalUpdate.cs
@@ -15,7 +15,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
 
         }
 
-        public GoalUpdate(DomainUser creator, Goal goal, UpdateType updatedType, string oldValue, string newValue)
+        public GoalUpdate(DomainUser creator, GoalItem goal, UpdateType updatedType, string oldValue, string newValue)
         {
             this.Creator = creator;
             this.CreatorId = creator.UserId;
@@ -29,7 +29,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
         public Guid Id { get; private set; }
         public DomainUser Creator { get; private set; }
         public Guid CreatorId { get; private set; }
-        public Goal Goal { get; private set; }
+        public GoalItem Goal { get; private set; }
         public Guid GoalId { get; private set; }
         public UpdateType UpdatedType { get; private set; }
         public string OldValue { get; private set; }
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Review.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Review.cs
index 13b586e..86b5776 100644
--- a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Review.cs
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Domains/Review.cs
@@ -15,7 +15,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
 
         }
 
-        public Review(DomainUser creator, Goal goal, string commentCreator, string commentOwner, bool isFinal)
+        public Review(DomainUser creator, GoalItem goal, string commentCreator, string commentOwner, bool isFinal)
         {
             this.Creator = creator;
             this.CreatorId = creator.UserId;
@@ -29,7 +29,7 @@ namespace Leuze.Modules.Goal.Domain.Domains
         public Guid Id { get; private set; }
         public DomainUser Creator { get; private set; }
         public Guid CreatorId { get; private set; }
-        public Goal Goal { get; private set; }
+        public GoalItem Goal { get; private set; }
         public Guid GoalId { get; private set; }
         public string CommentOwner { get; private set; }
         public string CommentCreator { get; private set; }
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/CommentRegistrar.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/CommentRegistrar.cs
new file mode 100644
index 0000000..aca4b31
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/CommentRegistrar.cs
@@ -0,0 +1,28 @@
+﻿using ExtCore.Data.EntityFramework;
+using Leuze.Modules.Goal.Domain.Domains;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Registrars
+{
+    public class CommentRegistrar : IEntityRegistrar
+    {
+        public void RegisterEntities(ModelBuilder modelbuilder)
+        {
+            modelbuilder.Entity<Comment>(etb =>
+            {
+                etb.HasKey(e => e.Id);
+                etb.Property(e => e.Id).ValueGeneratedOnAdd();
+                etb.HasOne(e => e.Creator).WithMany().HasForeignKey(e => e.CreatorId);
+                etb.HasOne(e => e.Goal).WithMany(e => e.Comments).HasForeignKey(e => e.GoalId);
+                etb.Property(e => e.Text).IsRequired();
+
+                etb.ToTable("Leuze_Modules_Goal_Domain_Comments");
+            });
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalDefinitionRegistrar.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalDefinitionRegistrar.cs
new file mode 100644
index 0000000..7d80f18
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalDefinitionRegistrar.cs
@@ -0,0 +1,33 @@
+﻿using ExtCore.Data.EntityFramework;
+using Leuze.Modules.Goal.Domain.Domains;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Registrars
+{
+    public class GoalDefinitionRegistrar : IEntityRegistrar
+    {
+        public void RegisterEntities(ModelBuilder modelbuilder)
+        {
+            modelbuilder.Entity<GoalDefinition>(etb =>
+            {
+                etb.HasKey(e => e.Id);
+                etb.Property(e => e.Id).ValueGeneratedOnAdd();
+                etb.HasOne(e => e.Creator).WithMany().HasForeignKey(e => e.CreatorId);
+                etb.HasOne(e => e.Owner).WithMany().HasForeignKey(e => e.OwnerId);
+                etb.Property(e => e.Name).IsRequired().HasMaxLength(255);
+                etb.Property(e => e.From).IsRequired();
+                etb.Property(e => e.To).IsRequired();
+                etb.Property(e => e.Vari).IsRequired(false);
+                etb.HasMany(e => e.Goals).WithOne(e => e.GoalDefinition).HasForeignKey(e => e.GoalDefinitionId);
+
+
+                etb.ToTable("Leuze_Modules_Goal_Domain_GoalDefinitions");
+            });
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalRegistrar.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalRegistrar.cs
new file mode 100644
index 0000000..ac771df
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalRegistrar.cs
@@ -0,0 +1,31 @@
+﻿using ExtCore.Data.EntityFramework;
+using Leuze.Modules.Goal.Domain.Domains;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Registrars
+{
+    public class GoalRegistrar : IEntityRegistrar
+    {
+        public void RegisterEntities(ModelBuilder modelbuilder)
+        {
+            modelbuilder.Entity<GoalItem>(etb =>
+            {
+                etb.HasKey(e => e.Id);
+                etb.Property(e => e.Id).ValueGeneratedOnAdd();
+                etb.HasOne(e => e.GoalDefinition).WithMany(e => e.Goals).HasForeignKey(e => e.GoalDefinitionId);
+                etb.HasOne(e => e.Creator).WithMany().HasForeignKey(e => e.CreatorId);
+                etb.Property(e => e.Name).IsRequired().HasMaxLength(255);
+                etb.HasMany(e => e.Comments).WithOne(e => e.Goal).HasForeignKey(e => e.GoalId);
+                etb.HasMany(e => e.Updates).WithOne(e => e.Goal).HasForeignKey(e => e.GoalId);
+                etb.HasMany(e => e.Reviews).WithOne(e => e.Goal).HasForeignKey(e => e.GoalId);
+
+                etb.ToTable("Leuze_Modules_Goal_Domain_GoalItems");
+            });
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalUpdateRegistrar.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalUpdateRegistrar.cs
new file mode 100644
index 0000000..f14fdda
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/GoalUpdateRegistrar.cs
@@ -0,0 +1,30 @@
+﻿using ExtCore.Data.EntityFramework;
+using Leuze.Modules.Goal.Domain.Domains;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Registrars
+{
+    public class GoalUpdateRegistrar : IEntityRegistrar
+    {
+        public void RegisterEntities(ModelBuilder modelbuilder)
+        {
+            modelbuilder.Entity<GoalUpdate>(etb =>
+            {
+                etb.HasKey(e => e.Id);
+                etb.Property(e => e.Id).ValueGeneratedOnAdd();
+                etb.HasOne(e => e.Creator).WithMany().HasForeignKey(e => e.CreatorId);
+                etb.HasOne(e => e.Goal).WithMany(e => e.Updates).HasForeignKey(e => e.GoalId);
+                etb.Property(e => e.UpdatedType).IsRequired();
+                etb.Property(e => e.OldValue).IsRequired();
+                etb.Property(e => e.NewValue).IsRequired();
+
+                etb.ToTable("Leuze_Modules_Goal_Domain_GoalUpdates");
+            });
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/ReviewRegistrar.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/ReviewRegistrar.cs
new file mode 100644
index 0000000..5bc000b
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Registrars/ReviewRegistrar.cs
@@ -0,0 +1,27 @@
+﻿using ExtCore.Data.EntityFramework;
+using Leuze.Modules.Goal.Domain.Domains;
+using Microsoft.EntityFrameworkCore;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Registrars
+{
+    public class ReviewRegistrar : IEntityRegistrar
+    {
+        public void RegisterEntities(ModelBuilder modelbuilder)
+        {
+            modelbuilder.Entity<Review>(etb =>
+            {
+                etb.HasKey(e => e.Id);
+                etb.Property(e => e.Id).ValueGeneratedOnAdd();
+                etb.HasOne(e => e.Creator).WithMany().HasForeignKey(e => e.CreatorId);
+                etb.HasOne(e => e.Goal).WithMany(e => e.Reviews).HasForeignKey(e => e.GoalId);
+
+                etb.ToTable("Leuze_Modules_Goal_Domain_Reviews");
+            });
+        }
+    }
+}
