Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Switch to Minimal API #720

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions CleanArchitecture.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain.UnitTests", "tests\D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Application.IntegrationTests", "tests\Application.IntegrationTests\Application.IntegrationTests.csproj", "{277029AF-D9E1-4B75-9F11-48FEA7345AD7}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI", "src\WebUI\WebUI.csproj", "{22454EE9-16B3-4B7A-8352-37E59B858155}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E2DA20AA-28D1-455C-BF50-C49A8F831633}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.gitignore = .gitignore
global.json = global.json
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI", "src\WebUI\WebUI.csproj", "{D62B82F7-3317-4BB4-85B2-3116C50C7585}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebUI.AcceptanceTests", "tests\WebUI.AcceptanceTests\WebUI.AcceptanceTests.csproj", "{006B607C-D181-47EC-82D7-06582A0F31DE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -58,10 +60,14 @@ Global
{277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{277029AF-D9E1-4B75-9F11-48FEA7345AD7}.Release|Any CPU.Build.0 = Release|Any CPU
{22454EE9-16B3-4B7A-8352-37E59B858155}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{22454EE9-16B3-4B7A-8352-37E59B858155}.Debug|Any CPU.Build.0 = Debug|Any CPU
{22454EE9-16B3-4B7A-8352-37E59B858155}.Release|Any CPU.ActiveCfg = Release|Any CPU
{22454EE9-16B3-4B7A-8352-37E59B858155}.Release|Any CPU.Build.0 = Release|Any CPU
{D62B82F7-3317-4BB4-85B2-3116C50C7585}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{D62B82F7-3317-4BB4-85B2-3116C50C7585}.Debug|Any CPU.Build.0 = Debug|Any CPU
{D62B82F7-3317-4BB4-85B2-3116C50C7585}.Release|Any CPU.ActiveCfg = Release|Any CPU
{D62B82F7-3317-4BB4-85B2-3116C50C7585}.Release|Any CPU.Build.0 = Release|Any CPU
{006B607C-D181-47EC-82D7-06582A0F31DE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{006B607C-D181-47EC-82D7-06582A0F31DE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{006B607C-D181-47EC-82D7-06582A0F31DE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{006B607C-D181-47EC-82D7-06582A0F31DE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -73,7 +79,8 @@ Global
{DEFF4009-1FAB-4392-80B6-707E2DC5C00B} = {664D406C-2F83-48F0-BFC3-408D5CB53C65}
{DC37FD87-552C-4613-9F16-1537CA522898} = {664D406C-2F83-48F0-BFC3-408D5CB53C65}
{277029AF-D9E1-4B75-9F11-48FEA7345AD7} = {664D406C-2F83-48F0-BFC3-408D5CB53C65}
{22454EE9-16B3-4B7A-8352-37E59B858155} = {6ED356A7-8B47-4613-AD01-C85CF28491BD}
{D62B82F7-3317-4BB4-85B2-3116C50C7585} = {6ED356A7-8B47-4613-AD01-C85CF28491BD}
{006B607C-D181-47EC-82D7-06582A0F31DE} = {664D406C-2F83-48F0-BFC3-408D5CB53C65}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3CB609D9-5D54-4C11-A371-DAAC8B74E430}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace CleanArchitecture.Application.WeatherForecasts.Queries.GetWeatherForecasts;

public record GetWeatherForecasts : IRequest<IEnumerable<WeatherForecast>>;
public record GetWeatherForecastsQuery : IRequest<IEnumerable<WeatherForecast>>;

public class GetWeatherForecastsQueryHandler : IRequestHandler<GetWeatherForecasts, IEnumerable<WeatherForecast>>
public class GetWeatherForecastsQueryHandler : IRequestHandler<GetWeatherForecastsQuery, IEnumerable<WeatherForecast>>
{
private static readonly string[] Summaries = new[]
{
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
};

#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously
public async Task<IEnumerable<WeatherForecast>> Handle(GetWeatherForecasts request, CancellationToken cancellationToken)
public async Task<IEnumerable<WeatherForecast>> Handle(GetWeatherForecastsQuery request, CancellationToken cancellationToken)
#pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously
{
var rng = new Random();
Expand Down
12 changes: 6 additions & 6 deletions src/WebUI/ClientApp/src/app/fetch-data/fetch-data.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { WeatherForecastClient, WeatherForecast } from '../web-api-client';
import { WeatherForecastsClient, WeatherForecast } from '../web-api-client';

@Component({
selector: 'app-fetch-data',
Expand All @@ -8,10 +8,10 @@ import { WeatherForecastClient, WeatherForecast } from '../web-api-client';
export class FetchDataComponent {
public forecasts: WeatherForecast[] = [];

constructor(private client: WeatherForecastClient) {
client.get().subscribe({
next: result => this.forecasts = result,
error: error => console.error(error)
});
constructor(private client: WeatherForecastsClient) {
client.getWeatherForecasts().subscribe({
next: result => this.forecasts = result,
error: error => console.error(error)
});
}
}
16 changes: 5 additions & 11 deletions src/WebUI/ClientApp/src/app/nav-menu/nav-menu.component.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<header>
<nav
class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3"
>
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
<div class="container">
<a class="navbar-brand" [routerLink]="['/']">WebUI</a>
<button
Expand All @@ -15,16 +13,12 @@
>
<span class="navbar-toggler-icon"></span>
</button>
<div
class="navbar-collapse collapse d-sm-inline-flex justify-content-end"
[ngClass]="{ show: isExpanded }"
>
<div class="navbar-collapse collapse d-sm-inline-flex justify-content-end"
[ngClass]="{ show: isExpanded }">
<ul class="navbar-nav flex-grow">
<li
class="nav-item"
<li class="nav-item"
[routerLinkActive]="['link-active']"
[routerLinkActiveOptions]="{ exact: true }"
>
[routerLinkActiveOptions]="{ exact: true }">
<a class="nav-link text-dark" [routerLink]="['/']">Home</a>
</li>
<li class="nav-item" [routerLinkActive]="['link-active']">
Expand Down
17 changes: 8 additions & 9 deletions src/WebUI/ClientApp/src/app/todo/todo.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class TodoComponent implements OnInit {
) {}

ngOnInit(): void {
this.listsClient.get().subscribe(
this.listsClient.getTodoLists().subscribe(
result => {
this.lists = result.lists;
this.priorityLevels = result.priorityLevels;
Expand Down Expand Up @@ -66,7 +66,7 @@ export class TodoComponent implements OnInit {
items: []
} as TodoListDto;

this.listsClient.create(list as CreateTodoListCommand).subscribe(
this.listsClient.createTodoList(list as CreateTodoListCommand).subscribe(
result => {
list.id = result;
this.lists.push(list);
Expand Down Expand Up @@ -97,7 +97,7 @@ export class TodoComponent implements OnInit {

updateListOptions() {
const list = this.listOptionsEditor as UpdateTodoListCommand;
this.listsClient.update(this.selectedList.id, list).subscribe(
this.listsClient.updateTodoList(this.selectedList.id, list).subscribe(
() => {
(this.selectedList.title = this.listOptionsEditor.title),
this.listOptionsModalRef.hide();
Expand All @@ -113,7 +113,7 @@ export class TodoComponent implements OnInit {
}

deleteListConfirmed(): void {
this.listsClient.delete(this.selectedList.id).subscribe(
this.listsClient.deleteTodoList(this.selectedList.id).subscribe(
() => {
this.deleteListModalRef.hide();
this.lists = this.lists.filter(t => t.id !== this.selectedList.id);
Expand All @@ -135,7 +135,7 @@ export class TodoComponent implements OnInit {

updateItemDetails(): void {
const item = this.itemDetailsEditor as UpdateTodoItemDetailCommand;
this.itemsClient.updateItemDetails(this.selectedItem.id, item).subscribe(
this.itemsClient.updateTodoItemDetail(this.selectedItem.id, item).subscribe(
() => {
if (this.selectedItem.listId !== this.itemDetailsEditor.listId) {
this.selectedList.items = this.selectedList.items.filter(
Expand Down Expand Up @@ -186,16 +186,15 @@ export class TodoComponent implements OnInit {

if (item.id === 0) {
this.itemsClient
.create({ title: item.title, listId: this.selectedList.id
} as CreateTodoItemCommand)
.createTodoItem({ title: item.title, listId: this.selectedList.id } as CreateTodoItemCommand)
.subscribe(
result => {
item.id = result;
},
error => console.error(error)
);
} else {
this.itemsClient.update(item.id, item as UpdateTodoItemCommand).subscribe(
this.itemsClient.updateTodoItem(item.id, item as UpdateTodoItemCommand).subscribe(
() => console.log('Update succeeded.'),
error => console.error(error)
);
Expand All @@ -217,7 +216,7 @@ export class TodoComponent implements OnInit {
const itemIndex = this.selectedList.items.indexOf(this.selectedItem);
this.selectedList.items.splice(itemIndex, 1);
} else {
this.itemsClient.delete(item.id).subscribe(
this.itemsClient.deleteTodoItem(item.id).subscribe(
() =>
(this.selectedList.items = this.selectedList.items.filter(
t => t.id !== item.id
Expand Down
Loading