Setting Up The Application Core Slides
Setting Up The Application Core Slides
Core
Gill Cleeren
CTO Xpirit Belgium
@gillcleeren | xpirit.com/gill
Understanding the business requirements
Overview Setting up the solution
Creating the domain
Designing the application project
- Contracts
- Packages
- Validation
- Exceptions
You’ve Seen The Finished Application
Understanding the Business Requirements
“Hello, I’m Mary Goodsale.
Manage events
Overview of events in their categories
Orders for the different events
Requirements for Ticket Management
Manage events
Overview of events in their categories
Orders for the different events
Wireframes for the Application
Event Management
Category Management
Ticket Sales
Setting up the Application Architecture
Translating to an Application Architecture
Backend Client
Blazor
Maui
ASP.NET
Core API
Angular
React
REST API
- Built using ASP.NET Core 6
- Clean architecture principles
- Data access using EF Core 6
Client
- Built using Blazor WebAssembly (ASP.NET
Core 6)
Class libraries
- .NET 6 Class Libraries
User interface
Interfaces
Entities
Application Core
Infrastructure
Demo
User interface
Interfaces
Entities
Application Core
Infrastructure
Achieving loose coupling in the
application core
- Contracts
- Messaging
Contracts
- Part of application core
- Functionality is described in interfaces
- Implemented in Core or Infrastructure
Using Repositories
Mediates between domain and data-
mapping layer
A C
B D
Object that wraps what
how objects need to
interact
A C
Avoid hard references
from one object to the
next Mediator
Creating a Request
public class GetEventsListQueryHandler :
IRequestHandler<GetEventsListQuery, List<EventListVm>>
{
public async Task<List<EventListVm>> Handle
(GetEventsListQuery request, CancellationToken cancellationToken)
{ }
}
Pipeline behaviour
- Logging
- Validation
- Caching
Mapping from an Entity to a View Model
Startup registration
NuGet package Profiles
in DI
var result = _mapper.Map<List<EventListVm>>(allEvents);
Disadvantages
- Added complexity
- Targeted at more complex applications
What Problem Are We Solving?
Translating Our Requirements to CQRS
Demo
Vertical slice
Features folder and subfolders
Splitting up in features
Creating a New Entity
[Required]
[StringLength(50)]
public string Name { get; set; }
public int Price { get; set; }
[Required]
[StringLength(50)]
public string Artist { get; set; }
}
Adding Fluent Validation
- Nuget package
- Uses lambda expressions for validation rules
Used exceptions
- NotFoundException
- BadRequestException
- ValidationException
public class NotFoundException : Exception
{
public NotFoundException(string name)
: base($"{name} is not found")
{ }
}
Bringing in the
application infrastructure