Skip to content

Commit

Permalink
👀 117 code review feedback matt goldman (#126)
Browse files Browse the repository at this point in the history
* Fixed broken links in ReadMe.md

* Removed AdAccount.cs and AdAccountInvalidException.cs

* Updated domain events

* Updated technology versions

* Added awesome CA link
  • Loading branch information
danielmackay authored Nov 17, 2023
1 parent ce31e91 commit cc56969
Show file tree
Hide file tree
Showing 11 changed files with 41 additions and 148 deletions.
37 changes: 26 additions & 11 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,35 @@
[![SSW TV | YouTube](https://img.shields.io/youtube/channel/views/UCBFgwtV9lIIhvoNh0xoQ7Pg?label=SSW%20TV%20%7C%20Views&style=social)](https://youtube.com/@SSWTV)

[![.NET](https://github.com/SSWConsulting/Northwind365/actions/workflows/dotnet.yml/badge.svg)](https://github.com/SSWConsulting/Northwind365/actions/workflows/dotnet.yml)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/dwyl/esta/issues)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/SSWConsulting/Northwind365/issues)

</div>

Northwind 365 is a sample application built using ASP.NET Core and Entity Framework Core. The architecture and
design of the project is explained in the video:

* [Clean Architecture with ASP.NET Core](https://youtu.be/_lwCVE_XgqI) ([slide deck](https://github.com/SSWConsulting/Northwind365/raw/main/Slides.pdf))
Northwind 365 is a sample application built using .NET 8, ASP.NET Core, and Entity Framework Core.

The initial construction of this project is explained in the following blog posts:

* [Code: Northwind Traders with Entity Framework Core](http://www.codingflow.net/northwind-traders-with-entity-framework-core/)
* [Create Northwind Traders Code First with Entity Framework Core – Part 1](http://www.codingflow.net/create-northwind-traders-code-first-with-entity-framework-core-part-1/)
* [Create Northwind Traders Code First with Entity Framework Core – Part 2](http://www.codingflow.net/create-northwind-traders-code-first-with-entity-framework-core-part-2/)
* [Code: Northwind Traders with Entity Framework Core](https://jasontaylor.dev/northwind-traders-with-entity-framework-core/)
* [Create Northwind Traders Code First with Entity Framework Core – Part 1](https://jasontaylor.dev/create-northwind-traders-code-first-with-entity-framework-core-part-1/)
* [Create Northwind Traders Code First with Entity Framework Core – Part 2](https://jasontaylor.dev/create-northwind-traders-code-first-with-entity-framework-core-part-2/)

## Learning Resources

You're interested learning more about Clean Architecture, please see this excellent video by Matt Goldman:

* [Clean Architecture with ASP.NET Core and MAUI](https://www.youtube.com/live/K9ryHflmQJE?si=VC2FtSZiAA3CxSsK)

Alternatively, SSW has many great rules about Clean Architecture:

* [SSW Rules - Clean Architecture](https://www.ssw.com.au/rules/rules-to-better-clean-architecture/)

If you'd like to start a new project using Clean Architecture, you can use the SSW Clean Architecture template:

* [SSW Clean Architecture Template](https://github.com/SSWConsulting/SSW.CleanArchitecture/)

You can also find a collection of commumity projects built on Clean Architecture here:

* [Awesome Clean Architecture](https://github.com/SSWConsulting/awesome-clean-architecture)

## Getting Started

Expand All @@ -31,9 +46,9 @@ Use these instructions to get the project up and running.
You will need the following tools:

* [Visual Studio or VS Code](https://visualstudio.microsoft.com/downloads/), or [Rider](https://www.jetbrains.com/rider/download/)
* [.NET 7 SDK](https://dotnet.microsoft.com/en-us/download)
* [Node.js](https://nodejs.org/en/) (version 10 or later) with npm (version 6.11.3 or later)
* Angular CLI (version 8.3.23 or later) - install by running `npm install -g @angular/cli`
* [.NET 8 SDK](https://dotnet.microsoft.com/en-us/download)
* [Node.js](https://nodejs.org/en/) (version 16 or later) with npm (version 7 or later)
* Angular CLI (version 15 or later) - install by running `npm install -g @angular/cli`

### Setup

Expand Down
2 changes: 1 addition & 1 deletion Src/Application/Common/Interfaces/INotificationService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Northwind.Application.Notifications.Models;
using Northwind.Application.Customers.EventHandlers;
using System.Threading.Tasks;

namespace Northwind.Application.Common.Interfaces;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ public async Task Handle(CreateCustomerCommand request, CancellationToken cancel

await _context.SaveChangesAsync(cancellationToken);

await _mediator.Publish(new CustomerCreated(entity.Id), cancellationToken);
await _mediator.Publish(new CustomerCreatedEvent(entity.Id), cancellationToken);
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using MediatR;
using Northwind.Application.Common.Interfaces;
using Northwind.Application.Notifications.Models;
using System.Threading;
using System.Threading.Tasks;
using Northwind.Domain.Customers;

namespace Northwind.Application.Customers.Commands.CreateCustomer;

public record CustomerCreated(CustomerId CustomerId) : INotification;
namespace Northwind.Application.Customers.EventHandlers;

// ReSharper disable once UnusedType.Global
public class CustomerCreatedHandler : INotificationHandler<CustomerCreated>
public class CustomerCreatedHandler : INotificationHandler<CustomerCreatedEvent>
{
private readonly INotificationService _notification;

Expand All @@ -19,8 +14,9 @@ public CustomerCreatedHandler(INotificationService notification)
_notification = notification;
}

public async Task Handle(CustomerCreated notification, CancellationToken cancellationToken)
public async Task Handle(CustomerCreatedEvent notification, CancellationToken cancellationToken)
{
await _notification.SendAsync(new MessageDto("From", "To", "Subject", "Body"));
// Publish notification to external service so welcome email can be sent
await _notification.SendAsync(new MessageDto("From", "To", "Subject - Welcome to Northwind365", "Body"));
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
namespace Northwind.Application.Notifications.Models;
namespace Northwind.Application.Customers.EventHandlers;

public record MessageDto(string From, string To, string Subject, string Body);
54 changes: 0 additions & 54 deletions Src/Domain/Common/AdAccount.cs

This file was deleted.

11 changes: 0 additions & 11 deletions Src/Domain/Common/Exceptions/AdAccountInvalidException.cs

This file was deleted.

5 changes: 5 additions & 0 deletions Src/Domain/Customers/CustomerCreatedEvent.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
using MediatR;

namespace Northwind.Domain.Customers;

public record CustomerCreatedEvent(CustomerId CustomerId) : INotification;
2 changes: 1 addition & 1 deletion Src/Infrastructure/Services/NotificationService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Northwind.Application.Common.Interfaces;
using Northwind.Application.Notifications.Models;
using Northwind.Application.Customers.EventHandlers;

namespace Northwind.Infrastructure.Services;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public void Handle_GivenValidRequest_ShouldRaiseCustomerCreatedNotification()

// Assert
mediatorMock.Received()
.Publish(Arg.Is<CustomerCreated>(cc => cc.CustomerId == newCustomerId), Arg.Any<CancellationToken>());
.Publish(Arg.Is<CustomerCreatedEvent>(cc => cc.CustomerId == newCustomerId), Arg.Any<CancellationToken>());
}
}
58 changes: 0 additions & 58 deletions Tests/Domain.UnitTests/ValueObjects/AdAccountTests.cs

This file was deleted.

0 comments on commit cc56969

Please sign in to comment.