commit af485ed9d183c743d163c6328df05fe012236118
Author: Milan Hotovec <silent@students.zcu.cz>
Date:   Sun Apr 25 19:11:21 2021 +0200

    Added GoalCreation

diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/Goals/Commands/CreateGoal.cs b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/Goals/Commands/CreateGoal.cs
new file mode 100644
index 0000000..15fd37f
--- /dev/null
+++ b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/CQRS/Goals/Commands/CreateGoal.cs
@@ -0,0 +1,54 @@
+﻿using Leuze.Core.Application.CQRS;
+using Leuze.Core.Domain.Domains.Users.Services.Abstractions;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Application.CQRS.Goals.Commands
+{
+    public static class CreateGoal
+    {
+        public record Command(Guid GoalDefinitionId, string Name, string Description) : IBaseRequest<Response>;
+
+        public record Response(GoalItem item);
+
+
+        public class Handler : IBaseRequestHandler<Command, Response>
+        {
+            private readonly IGoalItemRepository _goalItemRepo;
+            private readonly IGoalDefinitionRepository _goalDefinitionRepo;
+            private readonly IDomainUserProvider _domainUserProvider;
+
+            public Handler(IGoalItemRepository goalItemRepo, IGoalDefinitionRepository goalDefinitionRepo, IDomainUserProvider domainuserProvider)
+            {
+                _goalItemRepo = goalItemRepo;
+                _goalDefinitionRepo = goalDefinitionRepo;
+                _domainUserProvider = domainuserProvider;
+            }
+
+            public async Task<RequestResponse<Response>> Handle(Command request, CancellationToken cancellationToken)
+            {
+                //TODO: user muze byt null, ale to my nechceme!!!
+                var user = await _domainUserProvider.GetCurrentUserAsync();
+                var goalDef = await _goalDefinitionRepo.GetByIdAsync(request.GoalDefinitionId);
+
+                if(goalDef == null)
+                {
+                    return RequestResponse<Response>.CreateErrorResponse($"Goal definition with id: {request.GoalDefinitionId} not found!");
+                }
+
+                GoalItem item = new(goalDef, user, request.Name, request.Description);
+
+                await _goalItemRepo.AddAsync(item);
+
+                return RequestResponse<Response>.CreateSuccessResponse(new(item));
+            }
+        }
+
+    }
+}
diff --git a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/Class1.cs b/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/Class1.cs
deleted file mode 100644
index 80bfef6..0000000
--- a/src/Modules/Goal/Application/Leuze.Modules.Goal.Application/Class1.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-﻿using System;
-
-namespace Leuze.Modules.Goal.Application
-{
-    public class Class1
-    {
-    }
-}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
new file mode 100644
index 0000000..4e47a70
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/ICommentRepository.cs
@@ -0,0 +1,13 @@
+﻿using ExtCore.Data.Abstractions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Repositories
+{
+    public interface ICommentRepository : IRepository
+    {
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
new file mode 100644
index 0000000..f744dc6
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalDefinitionRepository.cs
@@ -0,0 +1,15 @@
+﻿using ExtCore.Data.Abstractions;
+using Leuze.Modules.Goal.Domain.Domains;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Repositories
+{
+    public interface IGoalDefinitionRepository : IRepository
+    {
+        Task<GoalDefinition> GetByIdAsync(Guid id); 
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
new file mode 100644
index 0000000..48da67e
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalItemRepository.cs
@@ -0,0 +1,16 @@
+﻿using ExtCore.Data.Abstractions;
+using Leuze.Modules.Goal.Domain.Domains;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Repositories
+{
+    public interface IGoalItemRepository : IRepository
+    {
+
+        Task AddAsync(GoalItem item);
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalUpdateRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalUpdateRepository.cs
new file mode 100644
index 0000000..1010567
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IGoalUpdateRepository.cs
@@ -0,0 +1,13 @@
+﻿using ExtCore.Data.Abstractions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Repositories
+{
+    public interface IGoalUpdateRepository : IRepository
+    {
+    }
+}
diff --git a/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IReviewRepository.cs b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IReviewRepository.cs
new file mode 100644
index 0000000..2591765
--- /dev/null
+++ b/src/Modules/Goal/Domain/Leuze.Modules.Goal.Domain/Repositories/IReviewRepository.cs
@@ -0,0 +1,13 @@
+﻿using ExtCore.Data.Abstractions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Domain.Repositories
+{
+    public interface IReviewRepository : IRepository
+    {
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Extensions/RepositoriesExtension.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Extensions/RepositoriesExtension.cs
index 6df9c1f..45101ef 100644
--- a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Extensions/RepositoriesExtension.cs
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Extensions/RepositoriesExtension.cs
@@ -1,4 +1,6 @@
-﻿using Microsoft.Extensions.DependencyInjection;
+﻿using Leuze.Modules.Goal.Domain.Repositories;
+using Leuze.Modules.Goal.Infrastructure.Persistence.Repositories;
+using Microsoft.Extensions.DependencyInjection;
 
 namespace Leuze.Modules.Goal.Infrastructure.Persistence.Extensions
 {
@@ -13,7 +15,11 @@ namespace Leuze.Modules.Goal.Infrastructure.Persistence.Extensions
         /// <param name="services"></param>
         public static void AddRepositories(this IServiceCollection services)
         {
-            //TODO: Insert needed
+            services.AddTransient<ICommentRepository,CommentRepository>();
+            services.AddTransient<IGoalDefinitionRepository,GoalDefinitionRepository>();
+            services.AddTransient<IGoalItemRepository,GoalItemRepository>();
+            services.AddTransient<IGoalUpdateRepository,GoalUpdateRepository>();
+            services.AddTransient<IReviewRepository,ReviewRepository>();
         }
 
     }
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
new file mode 100644
index 0000000..fe7e0aa
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/CommentRepository.cs
@@ -0,0 +1,20 @@
+﻿using AutoMapper;
+using ExtCore.Data.Abstractions;
+using Leuze.Core.Infrastructure.Persistence;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
+{
+    public class CommentRepository : RepositoryBase<Comment>, ICommentRepository
+    {
+        public CommentRepository(IStorageContext context, IMapper mapper) : base(context, mapper)
+        {
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
new file mode 100644
index 0000000..4f599fe
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalDefinitionRepository.cs
@@ -0,0 +1,27 @@
+﻿using AutoMapper;
+using ExtCore.Data.Abstractions;
+using Leuze.Core.Infrastructure.Persistence;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+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.Repositories
+{
+    public class GoalDefinitionRepository : RepositoryBase<GoalDefinition>, IGoalDefinitionRepository
+    {
+
+        public GoalDefinitionRepository(IStorageContext context, IMapper mapper) : base(context, mapper)
+        {
+        }
+
+        public async Task<GoalDefinition> GetByIdAsync(Guid id)
+        {
+            return await dbSet.Where(item => item.Id == id).SingleOrDefaultAsync();
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
new file mode 100644
index 0000000..a4add8c
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalItemRepository.cs
@@ -0,0 +1,26 @@
+﻿using AutoMapper;
+using ExtCore.Data.Abstractions;
+using Leuze.Core.Infrastructure.Persistence;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
+{
+    public class GoalItemRepository : RepositoryBase<GoalItem>, IGoalItemRepository
+    {
+        public GoalItemRepository(IStorageContext context, IMapper mapper) : base(context, mapper)
+        {
+        }
+
+        public async Task AddAsync(GoalItem item)
+        {
+            await dbSet.AddAsync(item);
+            await storageContext.SaveChangesAsync();
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalUpdateRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalUpdateRepository.cs
new file mode 100644
index 0000000..8737c34
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/GoalUpdateRepository.cs
@@ -0,0 +1,20 @@
+﻿using AutoMapper;
+using ExtCore.Data.Abstractions;
+using Leuze.Core.Infrastructure.Persistence;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
+{
+    public class GoalUpdateRepository : RepositoryBase<GoalUpdate>, IGoalUpdateRepository
+    {
+        public GoalUpdateRepository(IStorageContext context, IMapper mapper) : base(context, mapper)
+        {
+        }
+    }
+}
diff --git a/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/ReviewRepository.cs b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/ReviewRepository.cs
new file mode 100644
index 0000000..1257ccd
--- /dev/null
+++ b/src/Modules/Goal/Infrastructure/Leuze.Modules.Goal.Infrastructure.Persistence/Repositories/ReviewRepository.cs
@@ -0,0 +1,20 @@
+﻿using AutoMapper;
+using ExtCore.Data.Abstractions;
+using Leuze.Core.Infrastructure.Persistence;
+using Leuze.Modules.Goal.Domain.Domains;
+using Leuze.Modules.Goal.Domain.Repositories;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Leuze.Modules.Goal.Infrastructure.Persistence.Repositories
+{
+    public class ReviewRepository : RepositoryBase<Review>, IReviewRepository
+    {
+        public ReviewRepository(IStorageContext context, IMapper mapper) : base(context, mapper)
+        {
+        }
+    }
+}
