Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
01abd59
update solution structure
phongnguyend Jan 25, 2020
d721139
typo issues
phongnguyend Jan 26, 2020
a0e02eb
display messages from notification server
phongnguyend Jan 27, 2020
0faf108
add health check for notification server
phongnguyend Jan 27, 2020
826cccc
update application urls
phongnguyend Jan 27, 2020
b3a487d
add more screenshots
phongnguyend Jan 28, 2020
7e3e834
Add Health Checks for Storage Options (#26)
phongnguyend Jan 28, 2020
41649b9
Add Health Checks for Message Broker Options (#27)
phongnguyend Jan 28, 2020
d2c5d69
remove unnecessary migration steps
phongnguyend Jan 29, 2020
d550a4a
update urls
phongnguyend Jan 29, 2020
5611e13
configure docker-compose
phongnguyend Jan 30, 2020
3571d6c
configure docker-compose
phongnguyend Jan 30, 2020
28a6c01
configure docker-compose
phongnguyend Jan 30, 2020
b1fbac6
update alignment
phongnguyend Jan 30, 2020
715872f
configure docker-compose
phongnguyend Jan 30, 2020
9de4fb2
Update README.md
phongnguyend Jan 30, 2020
d74369e
view + refresh tokens
phongnguyend Jan 31, 2020
ed83303
strongly typed configuration
phongnguyend Jan 31, 2020
1cf2530
Configuring Authentication & Authorization for Hangfire Dashboard (#30)
phongnguyend Feb 8, 2020
356b453
Configuring Authentication & Authorization for Hangfire Dashboard (#30)
phongnguyend Feb 8, 2020
8d6ecf1
Adding Blazor (#28)
phongnguyend Feb 15, 2020
be9ea91
update documentation
phongnguyend Feb 15, 2020
e3e6dbc
EOL Conversion -> Unix (LF)
phongnguyend Feb 15, 2020
840555a
Update README.md
phongnguyend Feb 15, 2020
19e8ca5
support for angular fundamentals course
phongnguyend Feb 16, 2020
68db1eb
Stores Management
phongnguyend Feb 16, 2020
4152374
Create README.md
phongnguyend Feb 21, 2020
fa50587
Domain Events
phongnguyend Feb 22, 2020
9fc01d4
AggregateRoot
phongnguyend Feb 22, 2020
92b3dc1
rename projects
phongnguyend Feb 23, 2020
5b28e34
reorganize folders
phongnguyend Feb 24, 2020
efde7a3
reorganize folders
phongnguyend Feb 24, 2020
6cee9fc
update images
phongnguyend Feb 24, 2020
c4e75c6
Adding Identity Server 4 Admin UI (#31)
phongnguyend Feb 29, 2020
7111c36
Adding Identity Server 4 Admin UI (#31)
phongnguyend Feb 29, 2020
351fa0e
Adding Identity Server 4 Admin UI (#31)
phongnguyend Feb 29, 2020
72a141d
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 1, 2020
e3f6c52
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 1, 2020
481978e
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 1, 2020
d1dc33b
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 1, 2020
e69550d
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 1, 2020
cb5b22d
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 7, 2020
3b3cff9
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 8, 2020
502db82
Adding Identity Server 4 Admin UI (#31)
phongnguyend Mar 8, 2020
b6f3775
Adding Angular (#32)
phongnguyend Mar 10, 2020
6cc96e3
fix: src/ClassifiedAds.Projects/ClassifiedAds.Domain/ClassifiedAds.Do…
snyk-bot Apr 24, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
90 changes: 83 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
| Project | Configuration File | Configuration Key |
| -------- | ------------------ | ----------------- |
| ClassifiedAds.Migrator | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.Migrator/appsettings.json) | ConnectionStrings:ClassifiedAds |
| ClassifiedAds.BackgroundServices | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.BackgroundServices/appsettings.json) | ConnectionStrings:ClassifiedAds |
| ClassifiedAds.BackgroundServer | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.BackgroundServer/appsettings.json) | ConnectionStrings:ClassifiedAds |
| ClassifiedAds.GRPC | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.GRPC/appsettings.json) | ConnectionStrings:ClassifiedAds |
| ClassifiedAds.IdentityServer | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.IdentityServer/appsettings.json) | ConnectionStrings:ClassifiedAds |
| ClassifiedAds.NotificationServer | [appsettings.json](/src/ClassifiedAds.Projects/ClassifiedAds.NotificationServer/appsettings.json) | |
Expand Down Expand Up @@ -152,7 +152,9 @@
"Password": "guest",
"ExchangeName": "amq.direct",
"RoutingKey_FileUploaded": "classifiedadds_fileuploaded",
"RoutingKey_FileDeleted": "classifiedadds_filedeleted"
"RoutingKey_FileDeleted": "classifiedadds_filedeleted",
"QueueName_FileUploaded": "classifiedadds_fileuploaded",
"QueueName_FileDeleted": "classifiedadds_filedeleted"
},
}
```
Expand Down Expand Up @@ -193,8 +195,82 @@
}
```

## How to Login on Identity Server:
- Option 1: Use default created account:
+ User Name: [email protected]
+ Password: v*7Un8b4rcN@<-RN
- Option 2: Register new account at https://localhost:44367/Account/Register
## Set Startup Projects
![alt text](/docs/imgs/startup-projects.png)

## Run or Debug the Solution
- Web MVC Home Page: https://localhost:44364/

![alt text](/docs/imgs/web-mvc-home-page.png)

- Navigate to Health Checks UI https://localhost:44364/healthchecks-ui#/healthchecks and make sure everything is green.

![alt text](/docs/imgs/health-checks-ui.png)

- Login on Identity Server:
+ Option 1: Use default created account:
+ User Name: [email protected]
+ Password: v*7Un8b4rcN@<-RN
+ Option 2: Register new account at https://localhost:44367/Account/Register

- Open Blazor Home Page at: https://localhost:44331

![alt text](/docs/imgs/blazor-home-page.png)

## How to Run on Docker Containers:
- Add Migrations if you haven't done on previous steps:
+ Install **dotnet-ef** cli:
```
dotnet tool install --global dotnet-ef --version="3.1"
```
+ Navigate to [ClassifiedAds.Migrator](/src/ClassifiedAds.Projects/ClassifiedAds.Migrator/) and run these commands:
```
dotnet ef migrations add Init --context AdsDbContext -o Migrations/AdsDb
dotnet ef migrations add Init --context ConfigurationDbContext -o Migrations/ConfigurationDb
dotnet ef migrations add Init --context PersistedGrantDbContext -o Migrations/PersistedGrantDb
```
- Make sure Line Ending for these files is Unix (LF):
| Project | File |
| -------- | ---- |
| ClassifiedAds.Migrator | [docker-entrypoint.sh](/src/ClassifiedAds.Projects/ClassifiedAds.Migrator/docker-entrypoint.sh) |
| ClassifiedAds.BackgroundServer | [docker-entrypoint.sh](/src/ClassifiedAds.Projects/ClassifiedAds.BackgroundServer/docker-entrypoint.sh) |
| ClassifiedAds.WebMVC | [docker-entrypoint.sh](/src/ClassifiedAds.Projects/ClassifiedAds.WebMVC/docker-entrypoint.sh) |

Otherwise you might encounter:
```
exec user process caused "no such file or directory"
```
Tip: Open Notepad++ -> Edit -> EOL Conversion -> Unix (LF)
- Navigate to [ClassifiedAds.Projects](/src/ClassifiedAds.Projects/) and run:
```
docker-compose build
docker-compose up
```
- Open Web MVC Home Page at: http://host.docker.internal:9003

![alt text](/docs/imgs/web-mvc-home-page.png)

- Navigate to Health Checks UI http://host.docker.internal:9003/healthchecks-ui#/healthchecks and make sure everything is green.

![alt text](/docs/imgs/health-checks-ui-container.png)

- Login on Identity Server:
+ Use default created account: [email protected] / v*7Un8b4rcN@<-RN
+ Register new account at http://host.docker.internal:9000/Account/Register

- Open Blazor Home Page at: http://host.docker.internal:9008

![alt text](/docs/imgs/blazor-home-page.png)

## Application URLs:
| Project | Launch URL | Docker Container URL| Docker Container URL|
| -------- | ---------- | ------------------- | ------------------- |
| BackgroundServer | https://localhost:44318 | http://localhost:9004 | http://host.docker.internal:9004 |
| Blazor | https://localhost:44331 | http://localhost:9008 | http://host.docker.internal:9008 |
| GRPC | https://localhost:5001 | https://localhost:9005 | https://host.docker.internal:9005 |
| IdentityServer | https://localhost:44367 | http://localhost:9000 | http://host.docker.internal:9000 |
| NotificationServer | https://localhost:44390 | http://localhost:9001 | http://host.docker.internal:9001 |
| WebAPI | https://localhost:44312 | http://localhost:9002 | http://host.docker.internal:9002 |
| WebMVC | https://localhost:44364 | http://localhost:9003 | http://host.docker.internal:9003 |
| GraphQL | [https://localhost:44392](https://localhost:44392/ui/playground) | [http://localhost:9006](http://localhost:9006/ui/playground) | [http://host.docker.internal:9006](http://host.docker.internal:9006/ui/playground) |
| Ocelot | [https://localhost:44340](https://localhost:44340/ocelot/products) | [http://localhost:9007](http://localhost:9007/ocelot/products) | [http://host.docker.internal:9007](http://host.docker.internal:9007/ocelot/products) |
7 changes: 7 additions & 0 deletions docs/Selenium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[SeleniumHQ](https://www.seleniumhq.org/)

[SeleniumHQ GitHub](https://github.com/SeleniumHQ)

[Chrome Driver](http://chromedriver.storage.googleapis.com/index.html)

[Automated Business Readable Web Tests with Selenium and SpecFlow | Jason Roberts | Pluralsight](https://app.pluralsight.com/library/courses/selenium-specflow-automated-business-readable-web-tests/table-of-contents)
Binary file added docs/imgs/blazor-home-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/imgs/code-solution-structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/health-checks-ui-container.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/health-checks-ui.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/imgs/onion-architecture.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="www.draw.io" modified="2020-01-25T08:15:59.957Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" etag="sJHA_i0oIfQalDtvdThM" version="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/oZzfqqIY5aX2wcp2jlDmnmlfdLqU2aY5UIOuSZmlUXafhgwKPjY+37BblVeLO2BeiTzbA13yrB9Nnl7SVjSBWFYz9RXKz2AmrJ5vMweMmzVkJqyLmQlLr0s18h8+QvMRQ5Xpqj7Cco6YvyUd2Ooa4MzjiukJxJ3OF7P1AL5D+HeFJf7OVG16PABzwIUP8WBfjAdX4+EPhiMsnvBbz8vzkeXCROKbPudZgYVLpHSwOIhKDXH5ze1czsZaf0dhyNA+gwSxhE58moigEL94bF4bU/HBYzSmqWB6DJkvaSxK21iAy8dmcY3y+uKwvsUty/eEl/zdNHt/LlV7buU1XT2VXHBVSetv9Vc6afrbmjZ/MczkuGQXyV8dTEJCt34skmISQA6f4auF8hStD5BTa/vc5DjTnq2cDrAzQI57MXL0d0RrTPQd9sie2idIUIL9SUD9TVKAdXNEuPa0u+POBirfkFUxL2ZVgG4SH9Fz41MOeMQKfp/QTXCCZ+xvczfHDjheD2uv0mZn+nZyRLP5UU75bUjzyybw6T8=</diagram></mxfile>
<mxfile host="www.draw.io" modified="2020-01-26T16:18:30.740Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" etag="SBqKUMroKtMDfXQfKo37" version="12.5.8"><diagram id="X8Ldh0YJBJTgAtryyvzB" name="Page-1">7Vpbc5s4GP01fnSGu/GjL3U2M93ZzqbbNI8KCFBXIEbIsb2/fiUQFyFiO+NLPW38YKNPEkjnfJcDeGQv0u09BXnyJwkhHllGuB3Zy5Fl+Z7Pv4VhVxkc06wMMUVhZeoYHtF/UBoNaV2jEBbKQEYIZihXjQHJMhgwxQYoJRt1WESwetUcxFAzPAYA69YnFLJEbss1WvsfEMVJfWXTkD0pqAdLQ5GAkGw6JvvTyF5QQlh1lG4XEAvsalyqeas3epuFUZixYyY8PRiL5edZ+ny//fZt8v1vz5kux7YrF8d29Y5hyAGQzYxk/GdOyToLoTiPwVuEsoTEJA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Itx6TYW/zq4izDZBAl3irsQMPAC3iyUx8T6ADlNbGsPkPnpURZ/rZ5xnekdgTvpac3JAGUDjHkXY0x/cLRCWE+7BxJtnzXOEwruQhKs0xKsM7NzOhGeM1HT8HSgHA7pF/Ni+sXWleMTfGnFyx7hWMMfYLIOjxCS/dx3c+zYh4tkI2C67EzeTw5vtv/UqV6RtH93sj/9Dw==</diagram></mxfile>
Binary file modified docs/imgs/onion-architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/startup-projects.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/imgs/the-clean-architecture.drawio
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<mxfile host="www.draw.io" modified="2020-01-25T08:18:39.824Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" etag="tErgLp99ecTqMIeexCR2" version="12.5.6"><diagram id="X8Ldh0YJBJTgAtryyvzB" name="Page-1">3Vrbcto6FP0aHmFs+RLzGOyQZKZnmtNMm+SpI2wBaozFyCJAv/5ItnyVAyQ1xqd5yFhbliyttbXXlsTAcFe7WwrXy39IgMIB0ILdwPAGADi2w/8Lwz41mLaWGhYUB6lJLwyP+DeSxuy1DQ5QXHmRERIyvK4afRJFyGcVG6SUbKuvzUlY/eoaLpBiePRhqFqfcMCWclqWVtjvEF4ssy/rmqxZwexlaYiXMCDbksm4GRguJYSlT6udi0KBXYZL2m76Tm0+MIoidkqDp3vN9b5cr15udz9+XD1/s82xN5TsvMFwIycsB8v2GQK8Fw42L0y2S8zQ4xr6ombL6ea2JVuFvKTzRxivUwbmeIf4RydzHIYuCQlNOjICiJy5z+0xo+QVlWps30GzOa9R5ySn+YYoQ7uSSc7xFpEVYnTPX5G1lpG2kP5mSPS3BXlmRtGy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C/ddFEtjKlyHJn7oDzZ3lyA700AJVFCG/5pWDHZRvUpuUYsgDpu6ACon5NcXHfEdxjqEJRlUdAvpIr3VD5vOYe3o9Yn3MTQ4tpaZc4YgaHTlm/PiVYuuHDE4tLzMbsmnQIPDmuQTeOEUx+qD5RTgvJEFXJOHPVD8LzsejOLiU7B8cd+P15N+2ZsymO8ZzrZmDSV/1PH6QHsdnR60zmh20ft2w9UaE1we+clplI7+vf/8+vm02bKN64tZpBDu4Fk9k4z76e8nodGk0yonKxRGMPyUmHW4Es5Sqx5LQSITZsa4XUv5SruuJrp9M4sW28wfHfXJo4yky9BlpV/N7ENiafqfSVmDjxeKnqukepvi9r3HzHw==</diagram></mxfile>
<mxfile host="www.draw.io" modified="2020-01-26T16:16:02.348Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.130 Safari/537.36" etag="qGw_Gf9ssJR-oZCe8xaf" version="12.5.8"><diagram id="X8Ldh0YJBJTgAtryyvzB" name="Page-1">3Vpdc+IqGP41Xuok5KPxssbadmbPbM92dtte7WCCyjYGh2DV/fUHEvIJVduN0bO96ISXQOB5Xt7nBexZ/nJ7S+Fq8Q8JUdQDRrjtWeMeAJ7r8f/CsMsMtmtkhjnFYWYyS8Mj/o2kMX9tjUOU1F5khEQMr+rGgMQxCljNBiklm/prMxLVv7qCc6QYHgMYqdYnHLKFnJZjlPY7hOeL/MumIWuWMH9ZGpIFDMmmYrJuepZPCWHZ03Lro0hgl+OStZu8U1sMjKKYHdPg6d7wx1+uly+32x8/rp6/ufZw3JfsvMFoLScsB8t2OQK8Fw42L4w2C8zQ4woGombD6ea2BVtGvGTyR5isMgZmeIv4R0czHEU+iQhNO7JCiLxZwO0Jo+QVVWrcwEPTGa9R5ySn+YYoQ9uKSc7xFpElYnTHX5G1jpW1kP5mSfQ3JXl2TtGiQlxhhNJh5kXPJab8QcL6AYiHXULsIC+0dRB7YGq5bjsQm0YdY0/F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M6joEzIHZ6IbMZgn39GbE+pib7FtKulzhgBodOGX8+I1i64cMXiMvszXZNNAIvH0qgbeOUYxL0PwynJeSYCqS8Geqnwfnw1EcnEv2945bezv5t60ZW3fFeKo1szfp0x7H50etU5oftH5ds9VahNcHvnJaZaO4rn//Or5tNlyrfuLWaQTbuxaPZOM+/nvJ6HRpaOVE5eIAxp8Skw43gnlKdcGSoCXC7ljXSyl/qdZdiK4fTeLZtvN7x310aOMpMgwYaVfzLyCw6X6m0lZg48Xyl6rZHqb8ua918x8=</diagram></mxfile>
Binary file modified docs/imgs/the-clean-architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/imgs/web-mvc-home-page.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
using ClassifiedAds.ApplicationServices;
using ClassifiedAds.ApplicationServices.Commands;
using ClassifiedAds.ApplicationServices.Decorators;
using ClassifiedAds.ApplicationServices.Queries;
using ClassifiedAds.Application;
using ClassifiedAds.Application.Commands;
using ClassifiedAds.Application.Decorators;
using ClassifiedAds.Application.Queries;
using ClassifiedAds.Domain.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;

namespace Microsoft.Extensions.DependencyInjection
{
public static class ApplicationServicesServiceCollectionExtensions
public static class ApplicationServicesExtensions
{
public static IServiceCollection AddMessageHandlers(this IServiceCollection services)
{
services.AddScoped<Dispatcher>();

List<Type> handlerTypes = typeof(ICommand).Assembly.GetTypes()
List<Type> handlerTypes = Assembly.GetExecutingAssembly().GetTypes()
.Where(x => x.GetInterfaces().Any(y => IsHandlerInterface(y)))
.Where(x => x.Name.EndsWith("Handler"))
.ToList();
Expand All @@ -25,9 +26,30 @@ public static IServiceCollection AddMessageHandlers(this IServiceCollection serv
AddHandler(services, type);
}

services.AddEventHandlers();

return services;
}

public static IServiceCollection AddEventHandlers(this IServiceCollection services)
{
var types = Assembly.GetExecutingAssembly().GetTypes()
.Where(x => x.GetInterfaces().Any(y => y.IsGenericType && y.GetGenericTypeDefinition() == typeof(IDomainEventHandler<>)))
.ToList();

foreach (Type type in types)
{
services.AddTransient(type);
}

return services;
}

public static void RegisterDomainEventHandlers(this IServiceProvider serviceProvider)
{
DomainEvents.RegisterHandlers(Assembly.GetExecutingAssembly(), serviceProvider);
}

private static void AddHandler(IServiceCollection services, Type type)
{
object[] attributes = type.GetCustomAttributes(false);
Expand Down Expand Up @@ -90,11 +112,15 @@ private static object GetParameter(ParameterInfo parameterInfo, object current,
Type parameterType = parameterInfo.ParameterType;

if (IsHandlerInterface(parameterType))
{
return current;
}

object service = provider.GetService(parameterType);
if (service != null)
{
return service;
}

throw new ArgumentException($"Type {parameterType} not found");
}
Expand All @@ -104,18 +130,24 @@ private static Type ToDecorator(object attribute)
Type type = attribute.GetType();

if (type == typeof(DatabaseRetryAttribute))
{
return typeof(DatabaseRetryDecorator<>);
}

if (type == typeof(AuditLogAttribute))
{
return typeof(AuditLogDecorator<>);
}

throw new ArgumentException(attribute.ToString());
}

private static bool IsHandlerInterface(Type type)
{
if (!type.IsGenericType)
{
return false;
}

Type typeDefinition = type.GetGenericTypeDefinition();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>ClassifiedAds.ApplicationServices</RootNamespace>
<CodeAnalysisRuleSet>ClassifiedAds.ApplicationServices.ruleset</CodeAnalysisRuleSet>
<CodeAnalysisRuleSet>ClassifiedAds.Application.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
Expand All @@ -18,7 +17,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ClassifiedAds.DomainServices\ClassifiedAds.DomainServices.csproj" />
<ProjectReference Include="..\ClassifiedAds.Domain\ClassifiedAds.Domain.csproj" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;

namespace ClassifiedAds.ApplicationServices.Commands
namespace ClassifiedAds.Application.Commands
{
public interface ICommand
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;

namespace ClassifiedAds.ApplicationServices.Commands
namespace ClassifiedAds.Application.Commands
{
public interface ICommandHandler<TCommand>
where TCommand : ICommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace ClassifiedAds.ApplicationServices.Decorators
namespace ClassifiedAds.Application.Decorators
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = true)]
public sealed class AuditLogAttribute : Attribute
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Newtonsoft.Json;
using ClassifiedAds.ApplicationServices.Commands;
using ClassifiedAds.Application.Commands;

namespace ClassifiedAds.ApplicationServices.Decorators
namespace ClassifiedAds.Application.Decorators
{
public class AuditLogDecorator<TCommand> : ICommandHandler<TCommand>
where TCommand : ICommand
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System;
using Newtonsoft.Json;
using ClassifiedAds.ApplicationServices.Commands;
using ClassifiedAds.Application.Commands;

namespace ClassifiedAds.ApplicationServices.Decorators
namespace ClassifiedAds.Application.Decorators
{
public sealed class AuditLoggingDecorator<TCommand> : ICommandHandler<TCommand>
where TCommand : ICommand
Expand Down
Loading