diff --git a/Kros.ProjectTemplates/Kros.ProjectTemplates.sln b/Kros.ProjectTemplates/Kros.ProjectTemplates.sln
index fa61482..ffdb9b2 100644
--- a/Kros.ProjectTemplates/Kros.ProjectTemplates.sln
+++ b/Kros.ProjectTemplates/Kros.ProjectTemplates.sln
@@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.28803.202
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E1564162-4243-4D6C-94D9-8ED3A327D3DC}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kros.CqrsDemoTemplate", "src\Kros.CqrsDemoTemplate\content\Kros.CqrsDemoTemplate.csproj", "{93CC1718-810F-4DE3-A8EF-581B344672FC}"
-EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Kros.CqrsTemplate", "src\Kros.CqrsTemplate\content\Kros.CqrsTemplate.csproj", "{8BF9522F-306A-48C4-A397-6F51560D34F3}"
EndProject
Global
@@ -15,10 +13,6 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {93CC1718-810F-4DE3-A8EF-581B344672FC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {93CC1718-810F-4DE3-A8EF-581B344672FC}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {93CC1718-810F-4DE3-A8EF-581B344672FC}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {93CC1718-810F-4DE3-A8EF-581B344672FC}.Release|Any CPU.Build.0 = Release|Any CPU
{8BF9522F-306A-48C4-A397-6F51560D34F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BF9522F-306A-48C4-A397-6F51560D34F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BF9522F-306A-48C4-A397-6F51560D34F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -28,7 +22,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
- {93CC1718-810F-4DE3-A8EF-581B344672FC} = {E1564162-4243-4D6C-94D9-8ED3A327D3DC}
{8BF9522F-306A-48C4-A397-6F51560D34F3} = {E1564162-4243-4D6C-94D9-8ED3A327D3DC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/Kros.CqrsDemoTemplate.nuspec b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/Kros.CqrsDemoTemplate.nuspec
deleted file mode 100644
index d830685..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/Kros.CqrsDemoTemplate.nuspec
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- Kros.Templates.CqrsProjectDemo
- 1.0.3
-
- Create ASP.NET Web Demo project by CQRS pattern.
-
- KROS a.s.
-
-
-
- Kros CQRS WebApi project template.
- https://github.com/Kros-sk/Kros.Templates
- https://en.gravatar.com/userimage/137934964/524e95fbd8c2e8779e02819ab6902bef.png
- false
- Copyright © KROS a.s.
- Kros;CQRS;MediatR;WebApi;ASP.NET-Core;template;demo
-
-
-
-
-
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/.template.config/template.json b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/.template.config/template.json
deleted file mode 100644
index 51ff3bc..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/.template.config/template.json
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "$schema": "http://json.schemastore.org/template",
- "author": "Kros a.s.",
- "classifications": [
- "Web",
- "WebAPI",
- "KROS a.s.",
- "CQRS",
- "KORM",
- "Demo"
- ],
- "identity": "Kros.CqrsDemoTemplate",
- "name": "Kros CQRS Demo ASP.NET Core Web API",
- "shortName": "kros-cqrs-demo",
- "sourceName": "Kros.CqrsDemoTemplate",
- "preferNameDirectory": true,
- "sources": [
- {
- "modifiers": [
- {
- "exclude": [ "README.md" ]
- }
- ]
- }
- ]
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommand.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommand.cs
deleted file mode 100644
index b462d95..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommand.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using MediatR;
-using Newtonsoft.Json;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Create ToDo command.
- ///
- public class CreateToDoCommand : IRequest
- {
- ///
- /// ToDo Name.
- ///
- public string Name { get; set; }
-
- ///
- /// Description.
- ///
- public string Description { get; set; }
-
- ///
- /// User Id.
- ///
- [JsonIgnore]
- public int UserId { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandHandler.cs
deleted file mode 100644
index b77748d..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandHandler.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Model;
-using Kros.CqrsDemoTemplate.Application.Notifications;
-using Kros.Utils;
-using Mapster;
-using MediatR;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Create ToDo Command Handler.
- ///
- public class CreateToDoCommandHandler: IRequestHandler
- {
- private readonly IToDoRepository _repository;
- private readonly IMediator _mediator;
-
- ///
- /// Ctor.
- ///
- /// ToDo repository.
- /// Mediator for publishing events.
- public CreateToDoCommandHandler(IToDoRepository repository, IMediator mediator)
- {
- _repository = Check.NotNull(repository, nameof(repository));
- _mediator = Check.NotNull(mediator, nameof(mediator));
- }
-
- ///
- public async Task Handle(CreateToDoCommand request, CancellationToken cancellationToken)
- {
- var toDo = request.Adapt();
- await _repository.CreateToDoAsync(toDo);
- await _mediator.Publish(new ToDoUpdated(toDo.Id, request.UserId));
-
- return toDo.Id;
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandValidator.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandValidator.cs
deleted file mode 100644
index 9f20f9f..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/CreateToDo/CreateToDoCommandValidator.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using FluentValidation;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Validator for .
- ///
- public class CreateToDoCommandValidator : AbstractValidator
- {
- ///
- /// Ctor.
- ///
- public CreateToDoCommandValidator()
- {
- RuleFor(x => x.Description).DescriptionValidation();
- RuleFor(x => x.Name).NameValidation();
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommand.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommand.cs
deleted file mode 100644
index 92ba058..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommand.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Commands.PipeLines;
-using MediatR;
-using Newtonsoft.Json;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Delete ToDo command.
- ///
- public class DeleteToDoCommand : IRequest, IUserResourceCommand
- {
- ///
- /// Ctor.
- ///
- /// ToDo id.
- /// User id.
- public DeleteToDoCommand(int id, int userId)
- {
- Id = id;
- UserId = userId;
- }
-
- ///
- /// Id.
- ///
- public int Id { get; }
-
- ///
- /// User Id.
- ///
- [JsonIgnore]
- public int UserId { get; }
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommandHandler.cs
deleted file mode 100644
index 4d6b7f0..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/DeleteToDo/DeleteToDoCommandHandler.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Model;
-using Kros.CqrsDemoTemplate.Application.Notifications;
-using Kros.Utils;
-using Mapster;
-using MediatR;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Create ToDo Command Handler.
- ///
- public class DeleteToDoCommandHandler: IRequestHandler
- {
- private readonly IToDoRepository _repository;
- private readonly IMediator _mediator;
-
- ///
- /// Ctor.
- ///
- /// ToDo repository.
- /// Mediator for publishing events.
- public DeleteToDoCommandHandler(IToDoRepository repository, IMediator mediator)
- {
- _repository = Check.NotNull(repository, nameof(repository));
- _mediator = Check.NotNull(mediator, nameof(mediator));
- }
-
- ///
- public async Task Handle(DeleteToDoCommand request, CancellationToken cancellationToken)
- {
- await _repository.DeleteToDoAsync(request.Id);
- await _mediator.Publish(new ToDoUpdated(request.Id, request.UserId));
-
- return Unit.Value;
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/IUserResourceCommand.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/IUserResourceCommand.cs
deleted file mode 100644
index afec455..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/IUserResourceCommand.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace Kros.CqrsDemoTemplate.Application.Commands.PipeLines
-{
- ///
- /// Interface, which describe command for changing user resource.
- ///
- public interface IUserResourceCommand
- {
- ///
- /// Id.
- ///
- int Id { get; }
-
- ///
- /// User id.
- ///
- int UserId { get; }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/ValidateUserPermissionPipelineBehavior.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/ValidateUserPermissionPipelineBehavior.cs
deleted file mode 100644
index 97033c2..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/PipeLines/ValidateUserPermissionPipelineBehavior.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using Kros.KORM;
-using Kros.Utils;
-using System.Linq;
-using MediatR;
-using System.Threading;
-using System.Threading.Tasks;
-using Kros.AspNetCore.Exceptions;
-using System;
-using Kros.KORM.Metadata.Attribute;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands.PipeLines
-{
- ///
- /// Pipeline behavior for validating if queried resource belong to user.
- ///
- /// Type of request.
- public class ValidateUserPermissionPipelineBehavior : IPipelineBehavior
- where TRequest : IUserResourceCommand
- {
- private readonly IDatabase _database;
-
- ///
- /// Ctor.
- ///
- /// Database.
- public ValidateUserPermissionPipelineBehavior(IDatabase database)
- {
- _database = Check.NotNull(database, nameof(database));
- }
-
- ///
- public async Task Handle(
- TRequest request,
- CancellationToken cancellationToken,
- RequestHandlerDelegate next)
- {
- var toDo = _database.Query().FirstOrDefault(t => t.Id == request.Id);
-
- if (toDo == null)
- {
- throw new NotFoundException();
- }
-
- if (toDo.UserId != request.UserId)
- {
- throw new ResourceIsForbiddenException(String.Format(Properties.Resources.ForbiddenMessage,
- request.UserId, typeof(ToDo), request.Id));
- }
-
- return await next(); ;
- }
-
- [Alias("ToDos")]
- private class ToDo
- {
- public int Id { get; set; }
-
- public int UserId { get; set; }
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommand.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommand.cs
deleted file mode 100644
index ef65577..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommand.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Commands.PipeLines;
-using MediatR;
-using Newtonsoft.Json;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Update ToDo command.
- ///
- public class UpdateToDoCommand : IRequest, IUserResourceCommand
- {
- ///
- /// Id.
- ///
- [JsonIgnore]
- public int Id { get; set; }
-
- ///
- /// ToDo Name.
- ///
- public string Name { get; set; }
-
- ///
- /// Description.
- ///
- public string Description { get; set; }
-
- ///
- /// User Id.
- ///
- [JsonIgnore]
- public int UserId { get; set; }
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandHandler.cs
deleted file mode 100644
index 5ba356f..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandHandler.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Model;
-using Kros.CqrsDemoTemplate.Application.Notifications;
-using Kros.Utils;
-using Mapster;
-using MediatR;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Update ToDo Command Handler.
- ///
- public class UpdateToDoCommandHandler: IRequestHandler
- {
- private readonly IToDoRepository _repository;
- private readonly IMediator _mediator;
-
- ///
- /// Ctor.
- ///
- /// ToDo repository.
- /// Mediator for publishing events.
- public UpdateToDoCommandHandler(IToDoRepository repository, IMediator mediator)
- {
- _repository = Check.NotNull(repository, nameof(repository));
- _mediator = Check.NotNull(mediator, nameof(mediator));
- }
-
- ///
- public async Task Handle(UpdateToDoCommand request, CancellationToken cancellationToken)
- {
- var toDo = request.Adapt();
- await _repository.UpdateToDoAsync(toDo);
- await _mediator.Publish(new ToDoUpdated(toDo.Id, request.UserId));
-
- return Unit.Value;
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandValidator.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandValidator.cs
deleted file mode 100644
index c58cc96..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/UpdateTodo/UpdateToDoCommandValidator.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using FluentValidation;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Validator for .
- ///
- public class UpdateToDoCommandValidator : AbstractValidator
- {
- ///
- /// Ctor.
- ///
- public UpdateToDoCommandValidator()
- {
- RuleFor(x => x.Description).DescriptionValidation();
- RuleFor(x => x.Name).NameValidation();
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/ValidationRules.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/ValidationRules.cs
deleted file mode 100644
index 59ecfe4..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Commands/ValidationRules.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using FluentValidation;
-
-namespace Kros.CqrsDemoTemplate.Application.Commands
-{
- ///
- /// Base validation rules.
- ///
- public static class ValidationRules
- {
- ///
- /// Validation rule for Description.
- ///
- /// Command type.
- /// Rule
- /// Validation rule
- public static IRuleBuilderOptions DescriptionValidation(this IRuleBuilder rule)
- => rule
- .NotEmpty()
- .NotNull()
- .MaximumLength(255);
-
- ///
- /// Validation rule for Name.
- ///
- /// Command type.
- /// Rule
- /// Validation rule
- public static IRuleBuilderOptions NameValidation(this IRuleBuilder rule)
- => rule
- .NotEmpty()
- .NotNull()
- .MaximumLength(50);
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/IToDoRepository.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/IToDoRepository.cs
deleted file mode 100644
index c7835cc..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/IToDoRepository.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Model
-{
- ///
- /// Interface which describe repository for persistating .
- ///
- public interface IToDoRepository
- {
- ///
- /// Create new todo in repository.
- ///
- /// Creating todo.
- Task CreateToDoAsync(ToDo toDo);
-
- ///
- /// Update todo in repository.
- ///
- /// Updating todo.
- Task UpdateToDoAsync(ToDo toDo);
-
- ///
- /// Delete ToDo by .
- ///
- /// ToDo id.
- Task DeleteToDoAsync(int id);
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDo.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDo.cs
deleted file mode 100644
index 0312280..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDo.cs
+++ /dev/null
@@ -1,44 +0,0 @@
-using Kros.KORM.Metadata;
-using Kros.KORM.Metadata.Attribute;
-using System;
-
-namespace Kros.CqrsDemoTemplate.Application.Model
-{
- ///
- /// ToDo model.
- ///
- [Alias("ToDos")]
- public class ToDo
- {
- ///
- /// Id.
- ///
- [Key(autoIncrementMethodType: AutoIncrementMethodType.Custom)]
- public int Id { get; set; }
-
- ///
- /// ToDo Name.
- ///
- public string Name { get; set; }
-
- ///
- /// Description.
- ///
- public string Description { get; set; }
-
- ///
- /// User Id.
- ///
- public int UserId { get; set; }
-
- ///
- /// Created.
- ///
- public DateTimeOffset Created { get; set; }
-
- ///
- /// Date time of last change.
- ///
- public DateTimeOffset LastChange { get; set; }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDoRepository.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDoRepository.cs
deleted file mode 100644
index bed3597..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Model/ToDoRepository.cs
+++ /dev/null
@@ -1,68 +0,0 @@
-using Kros.KORM;
-using Kros.Utils;
-using System;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Model
-{
- ///
- /// Repository for persistating .
- ///
- public class ToDoRepository : IToDoRepository
- {
- private IDatabase _database;
-
- ///
- /// Ctor.
- ///
- /// Database
- public ToDoRepository(IDatabase database)
- {
- _database = Check.NotNull(database, nameof(database));
- }
-
- ///
- public async Task CreateToDoAsync(ToDo toDo)
- {
- var todos = _database.Query().AsDbSet();
-
- toDo.Created = DateTimeOffset.Now;
- toDo.LastChange = DateTimeOffset.Now;
- todos.Add(toDo);
-
- await todos.CommitChangesAsync();
- }
-
- ///
- public async Task UpdateToDoAsync(ToDo toDo)
- {
- var todos = _database
- .Query()
- .Select(_editColumns.Value)
- .AsDbSet();
-
- toDo.LastChange = DateTimeOffset.Now;
- todos.Edit(toDo);
-
- await todos.CommitChangesAsync();
- }
-
- ///
- public async Task DeleteToDoAsync(int id)
- {
- var todos = _database.Query().AsDbSet();
- todos.Delete(new ToDo() { Id = id});
-
- await todos.CommitChangesAsync();
- }
-
- //Dočasne pokia KORM nevie injektovať Created a LastChange
- private static Lazy _editColumns
- = new Lazy(()
- => typeof(ToDo).GetProperties()
- .Where(p=> p.Name != nameof(ToDo.Created))
- .Select(p=> p.Name)
- .ToArray());
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Notifications/ToDoUpdated.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Notifications/ToDoUpdated.cs
deleted file mode 100644
index 2f03d90..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Notifications/ToDoUpdated.cs
+++ /dev/null
@@ -1,31 +0,0 @@
-using MediatR;
-
-namespace Kros.CqrsDemoTemplate.Application.Notifications
-{
- ///
- /// ToDo was updated notification.
- ///
- public class ToDoUpdated : INotification
- {
- ///
- /// Ctor.
- ///
- /// ToDo id.
- /// User id.
- public ToDoUpdated(int id, int userId)
- {
- Id = id;
- UserId = userId;
- }
-
- ///
- /// ToDo id.
- ///
- public int Id { get; }
-
- ///
- /// User id.
- ///
- public int UserId { get; }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetAllToDoHeadersQuery.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetAllToDoHeadersQuery.cs
deleted file mode 100644
index 7a26bfb..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetAllToDoHeadersQuery.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-using Kros.KORM.Metadata.Attribute;
-using MediatR;
-using System.Collections.Generic;
-
-namespace Kros.CqrsDemoTemplate.Application.Queries
-{
- ///
- /// Get all todo headers.
- ///
- public class GetAllToDoHeadersQuery : IRequest>
- {
- ///
- /// Ctor.
- ///
- /// User id.
- public GetAllToDoHeadersQuery(int userId)
- {
- UserId = userId;
- }
-
- ///
- /// User Id.
- ///
- public int UserId { get; }
-
- ///
- /// ToDo Header
- ///
- [Alias("ToDos")]
- public class ToDoHeader
- {
- ///
- /// ToDo Id.
- ///
- public int Id { get; set; }
-
- ///
- /// ToDo Name.
- ///
- public string Name { get; set; }
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDoQuery.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDoQuery.cs
deleted file mode 100644
index 6ff0a42..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDoQuery.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using Kros.KORM.Metadata.Attribute;
-using Kros.CqrsDemoTemplate.Application.Queries.PipeLines;
-using MediatR;
-using System;
-
-namespace Kros.CqrsDemoTemplate.Application.Queries
-{
- ///
- /// Get ToDo by Id.
- ///
- public class GetToDoQuery : IRequest, IUserResourceQuery
- {
- ///
- /// Ctor.
- ///
- /// User id.
- /// ToDo id.
- public GetToDoQuery(int todoId, int userId)
- {
- ToDoId = todoId;
- UserId = userId;
- }
-
- ///
- /// ToDo id.
- ///
- public int ToDoId { get; set; }
-
- ///
- /// User Id.
- ///
- public int UserId { get; }
-
- ///
- /// ToDo Header
- ///
- [Alias("ToDos")]
- public class ToDo : IUserResourceQueryResult
- {
- ///
- /// ToDo Id.
- ///
- public int Id { get; set; }
-
- ///
- /// ToDo Name.
- ///
- public string Name { get; set; }
-
- ///
- /// Description.
- ///
- public string Description { get; set; }
-
- ///
- /// Created.
- ///
- public DateTimeOffset Created { get; set; }
-
- ///
- /// Date time of last change.
- ///
- public DateTimeOffset LastChange { get; set; }
-
- ///
- /// User Id.
- ///
- public int UserId { get; set; }
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDosQueryHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDosQueryHandler.cs
deleted file mode 100644
index 9e473b9..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/GetToDosQueryHandler.cs
+++ /dev/null
@@ -1,71 +0,0 @@
-using Kros.KORM;
-using Kros.Utils;
-using MediatR;
-using System.Linq;
-using System.Collections.Generic;
-using System.Threading;
-using System.Threading.Tasks;
-using Microsoft.Extensions.Caching.Distributed;
-using System;
-using Microsoft.Extensions.Options;
-using Kros.CqrsDemoTemplate.Application.Notifications;
-
-namespace Kros.CqrsDemoTemplate.Application.Queries
-{
- ///
- /// Query handler for ToDo queries.
- ///
- public class GetToDosQueryHandler
- : IRequestHandler>,
- IRequestHandler,
- INotificationHandler
- {
- private readonly IDatabase _database;
- private readonly IDistributedCache _cache;
- private readonly IOptions _options;
-
- ///
- /// Ctor.
- ///
- /// Database.
- /// Cache.
- /// Caching option.
- public GetToDosQueryHandler(
- IDatabase database,
- IDistributedCache cache,
- IOptions options)
- {
- _database = Check.NotNull(database, nameof(database));
- _cache = Check.NotNull(cache, nameof(cache));
- _options = Check.NotNull(options, nameof(options));
- }
-
- ///
- public Task> Handle(
- GetAllToDoHeadersQuery request,
- CancellationToken cancellationToken)
- => _cache.GetAndSetAsync(
- GetKey(request.UserId),
- () => _database.Query().Where($"UserId = {request.UserId}").AsEnumerable(),
- _options.Value);
-
- ///
- public Task Handle(GetToDoQuery request, CancellationToken cancellationToken)
- => _cache.GetAndSetAsync(
- GetKey(request.ToDoId),
- () => _database.Query().First(t => t.Id == request.ToDoId),
- _options.Value);
-
- ///
- public Task Handle(ToDoUpdated notification, CancellationToken cancellationToken)
- {
- _cache.RemoveAsync(GetKey(notification.UserId));
- _cache.RemoveAsync(GetKey(notification.Id));
-
- return Task.CompletedTask;
- }
-
- private string GetKey(int id)
- => $"{typeof(T).Name}:{id}";
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUSerResourceQueryResult.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUSerResourceQueryResult.cs
deleted file mode 100644
index abc46a7..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUSerResourceQueryResult.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Kros.CqrsDemoTemplate.Application.Queries.PipeLines
-{
- ///
- /// Interface, which describe user resource result.
- ///
- public interface IUserResourceQueryResult
- {
- ///
- /// User id.
- ///
- int UserId { get; }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUserResourceQuery.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUserResourceQuery.cs
deleted file mode 100644
index f8d38c8..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/IUserResourceQuery.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-namespace Kros.CqrsDemoTemplate.Application.Queries.PipeLines
-{
- ///
- /// Interface, which describe query for user resource.
- ///
- public interface IUserResourceQuery
- {
- ///
- /// User id.
- ///
- int UserId { get; }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/ValidateUserPermissionPipelineBehavior.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/ValidateUserPermissionPipelineBehavior.cs
deleted file mode 100644
index 2243834..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Application/Queries/PipeLines/ValidateUserPermissionPipelineBehavior.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using Kros.AspNetCore.Exceptions;
-using MediatR;
-using System;
-using System.Threading;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Application.Queries.PipeLines
-{
- ///
- /// Pipeline behavior for validating if queried resource belong to user.
- ///
- /// Type of request.
- /// Type of response.
- public class ValidateUserPermissionPipelineBehavior : IPipelineBehavior
- where TRequest : IUserResourceQuery
- where TResponse : IUserResourceQueryResult
- {
-
- ///
- public async Task Handle(
- TRequest request,
- CancellationToken cancellationToken,
- RequestHandlerDelegate next)
- {
- var result = await next();
-
- if (result != null && result.UserId != request.UserId)
- {
- throw new ResourceIsForbiddenException(String.Format(Properties.Resources.ForbiddenMessage,
- request.UserId, typeof(TResponse), result.UserId));
- }
-
- return result;
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Controllers/ToDosController.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Controllers/ToDosController.cs
deleted file mode 100644
index 9ce6c52..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Controllers/ToDosController.cs
+++ /dev/null
@@ -1,93 +0,0 @@
-using Kros.CqrsDemoTemplate.Application.Commands;
-using Kros.CqrsDemoTemplate.Application.Queries;
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Routing;
-using System.Collections.Generic;
-using System.Threading.Tasks;
-
-namespace Kros.CqrsDemoTemplate.Controllers
-{
- ///
- /// ToDos controller
- ///
- [Route("api/[controller]")]
- [ApiController]
- public class ToDosController : ControllerBase
- {
- ///
- /// Get user ToDos.
- ///
- [HttpGet]
- [ProducesResponseType(200, Type = typeof(IEnumerable))]
- public async Task> Get()
- => await this.SendRequest(new GetAllToDoHeadersQuery(1));
-
- ///
- /// Get ToDo by id.
- ///
- /// Ok.
- /// Forbidden when user don't have permission for ToDo with .
- /// If ToDo with id doesn't exist.
- [HttpGet("{id}", Name = nameof(GetToDo))]
- [ProducesResponseType(200, Type = typeof(GetToDoQuery.ToDo))]
- [ProducesResponseType(403)]
- [ProducesResponseType(404)]
- public async Task GetToDo(int id)
- => await this.SendRequest(new GetToDoQuery(id, 1));
-
- ///
- /// Create new ToDo.
- ///
- /// Data for creating todo.
- /// Created. ToDo id in body.
- ///
- /// ToDo id.
- ///
- [HttpPost]
- [ProducesResponseType(201)]
- public async Task CreateToDo(CreateToDoCommand command)
- {
- command.UserId = 1;
-
- return await this.SendCreateCommand(command, nameof(GetToDo));
- }
-
- ///
- /// Update ToDo.
- ///
- /// Data for creating todo.
- /// ToDo id.
- /// Forbidden when user don't have permission for ToDo with .
- /// If ToDo with id doesn't exist.
- [HttpPut("{id}")]
- [ProducesResponseType(200)]
- [ProducesResponseType(403)]
- [ProducesResponseType(404)]
- public async Task UpdateToDo(int id, UpdateToDoCommand command)
- {
- command.UserId = 1;
- command.Id = id;
-
- await this.SendRequest(command);
-
- return Ok();
- }
-
- ///
- /// Delete ToDo.
- ///
- /// ToDo id.
- /// Forbidden when user don't have permission for ToDo with .
- /// If ToDo with id doesn't exist.
- [HttpDelete("{id}")]
- [ProducesResponseType(200)]
- [ProducesResponseType(403)]
- [ProducesResponseType(404)]
- public async Task DeleteToDo(int id)
- {
- await this.SendRequest(new DeleteToDoCommand(id, 1));
-
- return Ok();
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/RedisCacheOptions.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/RedisCacheOptions.cs
deleted file mode 100644
index c058c5d..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/RedisCacheOptions.cs
+++ /dev/null
@@ -1,23 +0,0 @@
-namespace Kros.CqrsDemoTemplate.Infrastructure
-{
- ///
- /// Redis cache options.
- ///
- public class RedisCacheOptions
- {
- ///
- /// Connection string.
- ///
- public string ConnectionString { get; set; }
-
- ///
- /// Instance name.
- ///
- public string InstanceName { get; set; }
-
- ///
- /// Use Redis cache? If then memory distributed cache is used.
- ///
- public bool UseRedis { get; set; } = false;
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/ServiceCollectionExtensions.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/ServiceCollectionExtensions.cs
deleted file mode 100644
index 421753c..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/ServiceCollectionExtensions.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-using FluentValidation.AspNetCore;
-using Microsoft.Extensions.Configuration;
-using Kros.KORM.Extensions.Asp;
-using System.Reflection;
-using MediatR;
-using Kros.CqrsDemoTemplate.Application.Queries.PipeLines;
-using Kros.MediatR.Extensions;
-using Kros.CqrsDemoTemplate.Application.Commands.PipeLines;
-using System.IO;
-using Swashbuckle.AspNetCore.Swagger;
-using System;
-using Microsoft.Extensions.Caching.Distributed;
-using Kros.CqrsDemoTemplate.Infrastructure;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- ///
- /// Extensions for registering services for this project to the DI container.
- ///
- public static class ServiceCollectionExtensions
- {
- ///
- /// Register fluent validation.
- ///
- /// MVC builder.
- /// MVC builder.
- public static IMvcCoreBuilder AddFluentValidation(this IMvcCoreBuilder builder)
- => builder.AddFluentValidation(o =>
- {
- o.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly());
- o.RunDefaultMvcValidationAfterFluentValidationExecutes = false;
- });
-
- ///
- /// Add KORM database.
- ///
- /// DI container.
- /// Configuration.
- public static void AddKormDatabase(this IServiceCollection services, IConfiguration configuration)
- => services.AddKorm(configuration)
- .InitDatabaseForIdGenerator()
- .AddKormMigrations(configuration, o =>
- {
- o.AddAssemblyScriptsProvider(Assembly.GetEntryAssembly(), "Kros.CqrsDemoTemplate.Infrastructure.SqlScripts");
- })
- .Migrate();
-
- ///
- /// Add MediatR.
- ///
- /// DI container.
- public static IServiceCollection AddMediatRDependencies(this IServiceCollection services)
- => services.AddMediatR(Assembly.GetExecutingAssembly())
- .AddPipelineBehaviorsForRequest()
- .AddPipelineBehaviorsForRequest()
- .AddMediatRNullCheckPostProcessor();
-
- ///
- /// Add MediatR.
- ///
- /// DI container.
- public static IServiceCollection AddSwagger(this IServiceCollection services)
- => services.AddSwaggerGen(c =>
- {
- c.SwaggerDoc("v1", new Info { Title = "ToDo API", Version = "v1" });
- var filePath = Path.Combine(AppContext.BaseDirectory, "Kros.CqrsDemoTemplate.xml");
-
- if (File.Exists(filePath))
- {
- c.IncludeXmlComments(filePath);
- }
- c.AddFluentValidationRules();
- });
-
- ///
- /// Add distributed cache.
- ///
- /// DI container.
- /// Configuration.
- public static IServiceCollection AddDistributedCache(this IServiceCollection services, IConfiguration configuration)
- {
- services.ConfigureOptions(configuration);
- var redisOptions = configuration.GetSection();
-
- if (redisOptions.UseRedis)
- {
- services.AddStackExchangeRedisCache(options =>
- {
- options.Configuration = redisOptions.ConnectionString;
- options.InstanceName = redisOptions.InstanceName;
- });
- }
- else
- {
- services.AddDistributedMemoryCache();
- }
-
- return services;
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190401001_AddToDosTable.sql b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190401001_AddToDosTable.sql
deleted file mode 100644
index e0a87fc..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190401001_AddToDosTable.sql
+++ /dev/null
@@ -1,17 +0,0 @@
-SET ANSI_NULLS ON
-GO
-
-SET QUOTED_IDENTIFIER ON
-GO
-
-CREATE TABLE [dbo].[ToDos](
- [Id] [int] NOT NULL,
- [Description] [nvarchar](255) NULL,
- [Name] [nvarchar](50) NULL,
- [Created] [datetime2](7) NULL,
- CONSTRAINT [PK_ToDos] PRIMARY KEY CLUSTERED
-(
- [Id] ASC
-)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
-) ON [PRIMARY]
-GO
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403001_AddUserIdColumn.sql b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403001_AddUserIdColumn.sql
deleted file mode 100644
index 75635c0..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403001_AddUserIdColumn.sql
+++ /dev/null
@@ -1,10 +0,0 @@
-SET ANSI_NULLS ON
-GO
-
-SET QUOTED_IDENTIFIER ON
-GO
-
-ALTER TABLE [dbo].[ToDos]
-ADD [UserId] [int] NOT NULL;
-
-CREATE INDEX [IX_ToDos_UserId] ON [dbo].[ToDos] ([UserId]);
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403002_InserDummyToDos.sql b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403002_InserDummyToDos.sql
deleted file mode 100644
index 1620fe7..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190403002_InserDummyToDos.sql
+++ /dev/null
@@ -1,12 +0,0 @@
-SET ANSI_NULLS ON
-GO
-
-SET QUOTED_IDENTIFIER ON
-GO
-
-INSERT INTO [dbo].[ToDos] ([Id], [Name], [Description], [UserId], [Created]) VALUES (1, 'CQRS', 'Study the CQRS design pattern', 1, '20190401 11:25:11 AM');
-INSERT INTO [dbo].[ToDos] ([Id], [Name], [Description], [UserId], [Created]) VALUES (2, 'MediatR', 'Study the MediatR project', 1, '20190402 10:15:09 AM');
-INSERT INTO [dbo].[ToDos] ([Id], [Name], [Description], [UserId], [Created]) VALUES (3, 'Create prototype', 'Create prototype with MediatR', 1, '20190402 10:40:00 AM');
-INSERT INTO [dbo].[ToDos] ([Id], [Name], [Description], [UserId], [Created]) VALUES (4, 'ToDo', 'ToDo for user 2', 2, '20190402 10:41:00 AM');
-
-INSERT INTO [dbo].[IdStore] VALUES ('ToDos', 4)
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411001_ChangeDateTimeToDateTimeOffset.sql b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411001_ChangeDateTimeToDateTimeOffset.sql
deleted file mode 100644
index d16e649..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411001_ChangeDateTimeToDateTimeOffset.sql
+++ /dev/null
@@ -1,18 +0,0 @@
-SET ANSI_NULLS ON
-GO
-
-SET QUOTED_IDENTIFIER ON
-GO
-
-ALTER TABLE [dbo].[ToDos]
-ADD [CreatedNew] [DATETIMEOFFSET];
-
-Go
-
-UPDATE [ToDos] SET [CreatedNew] = CONVERT(DATETIMEOFFSET, CONVERT(VARCHAR, [Created], 120) + RIGHT(CONVERT(VARCHAR, SYSDATETIMEOFFSET(), 120), 6), 120);
-
-ALTER TABLE [dbo].[ToDos] DROP COLUMN [Created];
-
-EXEC sys.sp_rename @objname = N'dbo.ToDos.CreatedNew',
- @newname = 'Created',
- @objtype = 'COLUMN'
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411002_AddLastChangeColumn.sql b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411002_AddLastChangeColumn.sql
deleted file mode 100644
index 09e3687..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Infrastructure/SqlScripts/20190411002_AddLastChangeColumn.sql
+++ /dev/null
@@ -1,14 +0,0 @@
-SET ANSI_NULLS ON
-GO
-
-SET QUOTED_IDENTIFIER ON
-GO
-
-ALTER TABLE [dbo].[ToDos]
-ADD [LastChange] [DATETIMEOFFSET];
-
-GO
-
-UPDATE [ToDos] SET [LastChange] = [Created]
-
-GO
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Kros.CqrsDemoTemplate.csproj b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Kros.CqrsDemoTemplate.csproj
deleted file mode 100644
index 355e6ba..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Kros.CqrsDemoTemplate.csproj
+++ /dev/null
@@ -1,86 +0,0 @@
-
-
-
- netcoreapp2.2
- InProcess
-
-
-
- bin\$(Configuration)\$(TargetFramework)\$(AssemblyName).xml
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
- PreserveNewest
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- True
- True
- Resources.resx
-
-
-
-
-
- ResXFileCodeGenerator
- Resources.Designer.cs
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Program.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Program.cs
deleted file mode 100644
index 1dd88b4..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Program.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using Microsoft.AspNetCore;
-using Microsoft.AspNetCore.Hosting;
-
-namespace Kros.CqrsDemoTemplate
-{
- ///
- /// Startup class.
- ///
- public class Program
- {
- ///
- /// Application entry.
- ///
- /// Arguments.
- public static void Main(string[] args)
- {
- CreateWebHostBuilder(args).Build().Run();
- }
-
- ///
- /// Create web host builder.
- ///
- /// Arguments.
- public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
- WebHost.CreateDefaultBuilder(args)
- .UseApplicationInsights()
- .UseStartup();
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.Designer.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.Designer.cs
deleted file mode 100644
index e119a5e..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.Designer.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-//------------------------------------------------------------------------------
-//
-// This code was generated by a tool.
-// Runtime Version:4.0.30319.42000
-//
-// Changes to this file may cause incorrect behavior and will be lost if
-// the code is regenerated.
-//
-//------------------------------------------------------------------------------
-
-namespace Kros.CqrsDemoTemplate.Properties {
- using System;
-
-
- ///
- /// A strongly-typed resource class, for looking up localized strings, etc.
- ///
- // This class was auto-generated by the StronglyTypedResourceBuilder
- // class via a tool like ResGen or Visual Studio.
- // To add or remove a member, edit your .ResX file then rerun ResGen
- // with the /str option, or rebuild your VS project.
- [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
- [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
- [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
- internal class Resources {
-
- private static global::System.Resources.ResourceManager resourceMan;
-
- private static global::System.Globalization.CultureInfo resourceCulture;
-
- [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
- internal Resources() {
- }
-
- ///
- /// Returns the cached ResourceManager instance used by this class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Resources.ResourceManager ResourceManager {
- get {
- if (object.ReferenceEquals(resourceMan, null)) {
- global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Kros.CqrsDemoTemplate.Properties.Resources", typeof(Resources).Assembly);
- resourceMan = temp;
- }
- return resourceMan;
- }
- }
-
- ///
- /// Overrides the current thread's CurrentUICulture property for all
- /// resource lookups using this strongly typed resource class.
- ///
- [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
- internal static global::System.Globalization.CultureInfo Culture {
- get {
- return resourceCulture;
- }
- set {
- resourceCulture = value;
- }
- }
-
- ///
- /// Looks up a localized string similar to User with id '{0}' tried access for '{1}' with id '{2}'..
- ///
- internal static string ForbiddenMessage {
- get {
- return ResourceManager.GetString("ForbiddenMessage", resourceCulture);
- }
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.resx b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.resx
deleted file mode 100644
index b4eca64..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Properties/Resources.resx
+++ /dev/null
@@ -1,124 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- text/microsoft-resx
-
-
- 2.0
-
-
- System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
-
-
- User with id '{0}' tried access for '{1}' with id '{2}'.
- {0} - user id. {1} - resource type. {2} - resource id.
-
-
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/README.md b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/README.md
deleted file mode 100644
index a636f61..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/README.md
+++ /dev/null
@@ -1,32 +0,0 @@
-# CQRS ToDo demo template
-
-## About
-`Kros.Templates.CqrsProjectDemo` is a template to create a demo project according to the CQRS pattern.
-Create **ToDo** sample demo ASP.NET Core WebApi application with our recommended directory structure, packages, configuration and basic logic.
-More info about the project structure and CQRS can be read in [demo example](https://github.com/Kros-sk/Kros.AspNetCore.BestPractices/blob/master/README.md).
-
-## Quick start
-
-1. Instal `Kros.Templates.CqrsProjectDemo` dotnet template from `nuget.org`.
- `dotnet new -i Kros.Templates.CqrsProjectDemo`
-2. Create directory and create your CQRS project.
- `dotnet new kros-cqrs-demo`
- dotnet-cli by this template create runnable project.
-4. Change connection string in `appsettings.local.json` to your `SQL Server`.
-
-```
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "Server={serverName};Initial Catalog={databaseName};Integrated Security=True;"
- },
-
- "KormMigrations": {
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "Server={serverName};Initial Catalog={databaseName};Integrated Security=True;"
- },
- "AutoMigrate": "True"
- }
-```
-
-5. Run and enjoy.
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Startup.cs b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Startup.cs
deleted file mode 100644
index 8cacb9f..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/Startup.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using Microsoft.AspNetCore.Builder;
-using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using FluentValidation.AspNetCore;
-using Microsoft.AspNetCore.BuilderMiddlewares;
-using Kros.AspNetCore;
-using Microsoft.Extensions.Logging;
-
-namespace Kros.CqrsDemoTemplate
-{
- ///
- /// Startup.
- ///
- public class Startup: BaseStartup
- {
- ///
- /// Ctor.
- ///
- /// Environment.
- public Startup(IHostingEnvironment env)
- : base(env)
- { }
-
-
- ///
- /// Configure IoC container.
- ///
- /// Service.
- public override void ConfigureServices(IServiceCollection services)
- {
- base.ConfigureServices(services);
-
- services.AddWebApi()
- .AddFluentValidation();
-
- services.AddKormDatabase(Configuration);
- services.AddMediatRDependencies();
-
- services.Scan(scan =>
- scan.FromCallingAssembly()
- .AddClasses()
- .AsMatchingInterface());
-
- services.AddSwagger();
- services.AddDistributedCache(Configuration);
- }
-
- ///
- /// Configure web api pipeline.
- ///
- /// Application builder.
- /// The logger factory.
- public override void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory)
- {
- base.Configure(app, loggerFactory);
-
- if (Environment.IsDevelopment())
- {
- app.UseDeveloperExceptionPage();
- }
- else
- {
- // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
- app.UseHsts();
- app.UseHttpsRedirection();
- }
-
- app.UseCors("AllowAllOrigins");
- app.UseErrorHandling();
- app.UseKormMigrations();
- app.UseMvc();
-
- app.UseSwagger();
- app.UseSwaggerUI(c =>
- {
- c.SwaggerEndpoint("/swagger/v1/swagger.json", "API V1");
- });
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.Development.json b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.Development.json
deleted file mode 100644
index e203e94..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.Development.json
+++ /dev/null
@@ -1,9 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
- }
-}
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.json b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.json
deleted file mode 100644
index f3202e5..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.json
+++ /dev/null
@@ -1,32 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Warning"
- }
- },
-
- "AllowedHosts": "*",
-
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "!!!secure connection string!!!"
- },
-
- "KormMigrations": {
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "!!!secure connection string!!!"
- },
- "AutoMigrate": "False"
- },
-
- "RedisCache": {
- "ConnectionString": "localhost:6379",
- "InstanceName": "local",
- "UseRedis": "true"
- },
-
- "DistributedCacheEntry": {
- "SlidingExpiration": "0.00:30:00"
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.local.json b/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.local.json
deleted file mode 100644
index 87e7b68..0000000
--- a/Kros.ProjectTemplates/src/Kros.CqrsDemoTemplate/content/appsettings.local.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "Logging": {
- "LogLevel": {
- "Default": "Debug",
- "System": "Information",
- "Microsoft": "Information"
- }
- },
-
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "Server={serverName};Initial Catalog={databaseName};Integrated Security=True;"
- },
-
- "KormMigrations": {
- "ConnectionString": {
- "ProviderName": "System.Data.SqlClient",
- "ConnectionString": "Server={serverName};Initial Catalog={databaseName};Integrated Security=True;"
- },
- "AutoMigrate": "True"
- },
-
- "RedisCache": {
- "ConnectionString": "localhost:6379",
- "InstanceName": "local",
- "UseRedis": "True"
- }
-}
\ No newline at end of file
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/Kros.CqrsTemplate.nuspec b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/Kros.CqrsTemplate.nuspec
index 5b214e2..e553d5c 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/Kros.CqrsTemplate.nuspec
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/Kros.CqrsTemplate.nuspec
@@ -2,7 +2,7 @@
Kros.Templates.CqrsProject
- 1.0.3
+ 1.0.4
Create ASP.NET Web project by CQRS pattern.
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/CreateRRREntityNameRRR_/CreateRRREntityNameRRR_CommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/CreateRRREntityNameRRR_/CreateRRREntityNameRRR_CommandHandler.cs
index dc7139a..8b18707 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/CreateRRREntityNameRRR_/CreateRRREntityNameRRR_CommandHandler.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/CreateRRREntityNameRRR_/CreateRRREntityNameRRR_CommandHandler.cs
@@ -1,4 +1,4 @@
-using Kros.CqrsTemplate.Application.Model;
+using Kros.CqrsTemplate.Domain;
using Kros.Utils;
using Mapster;
using MediatR;
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/DeleteRRREntityNameRRR_/DeleteRRREntityNameRRR_CommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/DeleteRRREntityNameRRR_/DeleteRRREntityNameRRR_CommandHandler.cs
index 3e26344..23858f1 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/DeleteRRREntityNameRRR_/DeleteRRREntityNameRRR_CommandHandler.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/DeleteRRREntityNameRRR_/DeleteRRREntityNameRRR_CommandHandler.cs
@@ -1,4 +1,4 @@
-using Kros.CqrsTemplate.Application.Model;
+using Kros.CqrsTemplate.Domain;
using Kros.Utils;
using MediatR;
using System.Threading;
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/UpdateRRREntityNameRRR_/UpdateRRREntityNameRRR_CommandHandler.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/UpdateRRREntityNameRRR_/UpdateRRREntityNameRRR_CommandHandler.cs
index 76c7827..491ef27 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/UpdateRRREntityNameRRR_/UpdateRRREntityNameRRR_CommandHandler.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Commands/UpdateRRREntityNameRRR_/UpdateRRREntityNameRRR_CommandHandler.cs
@@ -1,4 +1,4 @@
-using Kros.CqrsTemplate.Application.Model;
+using Kros.CqrsTemplate.Domain;
using Kros.Utils;
using Mapster;
using MediatR;
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Controllers/RRREntityNameRRR_Plural_Controller.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Controllers/RRREntityNameRRR_Plural_Controller.cs
similarity index 98%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Controllers/RRREntityNameRRR_Plural_Controller.cs
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Controllers/RRREntityNameRRR_Plural_Controller.cs
index 20ffec2..12e8d0d 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Controllers/RRREntityNameRRR_Plural_Controller.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Controllers/RRREntityNameRRR_Plural_Controller.cs
@@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Threading.Tasks;
-namespace Kros.CqrsTemplate.Controllers
+namespace Kros.CqrsTemplate.Application.Controllers
{
///
/// RRREntityNameRRR_Plural_ controller
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/ServiceCollectionExtensions.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/ServiceCollectionExtensions.cs
similarity index 97%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/ServiceCollectionExtensions.cs
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/ServiceCollectionExtensions.cs
index f8cfec3..767d790 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/ServiceCollectionExtensions.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/ServiceCollectionExtensions.cs
@@ -37,7 +37,7 @@ public static void AddKormDatabase(this IServiceCollection services, IConfigurat
.InitDatabaseForIdGenerator()
.AddKormMigrations(configuration, o =>
{
- o.AddAssemblyScriptsProvider(Assembly.GetEntryAssembly(), "Kros.CqrsTemplate.Infrastructure.SqlScripts");
+ o.AddAssemblyScriptsProvider(Assembly.GetEntryAssembly(), "Kros.CqrsTemplate.SqlScripts");
})
.Migrate();
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/IRRREntityNameRRR_Repository.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/IRRREntityNameRRR_Repository.cs
similarity index 94%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/IRRREntityNameRRR_Repository.cs
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/IRRREntityNameRRR_Repository.cs
index 9cd7177..7539966 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/IRRREntityNameRRR_Repository.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/IRRREntityNameRRR_Repository.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
-namespace Kros.CqrsTemplate.Application.Model
+namespace Kros.CqrsTemplate.Domain
{
///
/// Interface which describe repository for persistating .
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/RRREntityNameRRR_.cs
similarity index 89%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_.cs
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/RRREntityNameRRR_.cs
index cfa804d..467223c 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Domain/RRREntityNameRRR_.cs
@@ -1,7 +1,7 @@
using Kros.KORM.Metadata;
using Kros.KORM.Metadata.Attribute;
-namespace Kros.CqrsTemplate.Application.Model
+namespace Kros.CqrsTemplate.Domain
{
///
/// RRREntityNameRRR_ model.
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_Repository.cs b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/RRREntityNameRRR_Repository.cs
similarity index 93%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_Repository.cs
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/RRREntityNameRRR_Repository.cs
index 3358834..1a73551 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Application/Model/RRREntityNameRRR_Repository.cs
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/RRREntityNameRRR_Repository.cs
@@ -1,8 +1,9 @@
-using Kros.KORM;
+using Kros.CqrsTemplate.Domain;
+using Kros.KORM;
using Kros.Utils;
using System.Threading.Tasks;
-namespace Kros.CqrsTemplate.Application.Model
+namespace Kros.CqrsTemplate.Infrastructure
{
///
/// Repository for persistating .
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Kros.CqrsTemplate.csproj b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Kros.CqrsTemplate.csproj
index 469f90d..111456d 100644
--- a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Kros.CqrsTemplate.csproj
+++ b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Kros.CqrsTemplate.csproj
@@ -10,11 +10,11 @@
-
+
-
+
PreserveNewest
diff --git a/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/SqlScripts/20190424001_InitializationScript.sql b/Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/SqlScripts/20190424001_InitializationScript.sql
similarity index 100%
rename from Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/Infrastructure/SqlScripts/20190424001_InitializationScript.sql
rename to Kros.ProjectTemplates/src/Kros.CqrsTemplate/content/SqlScripts/20190424001_InitializationScript.sql