Skip to content

Commit

Permalink
🔥 Removed ExportTodos feature to simplify the template.
Browse files Browse the repository at this point in the history
  • Loading branch information
jasontaylordev committed Jul 8, 2023
1 parent bccad9d commit f791b65
Show file tree
Hide file tree
Showing 15 changed files with 3 additions and 210 deletions.
5 changes: 2 additions & 3 deletions CleanArchitecture.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
<metadata>

<id>Clean.Architecture.Solution.Template</id>
<version>8.0.0-preview.5.9</version>
<version>8.0.0-preview.5.10</version>
<title>Clean Architecture Solution Template</title>
<authors>JasonTaylorDev</authors>
<description>Clean Architecture Solution Template for .NET 8.</description>
<summary>
A Clean Architecture Solution Template for creating a Single-Page Application (SPA) with ASP.NET Core.
</summary>
<releaseNotes>
Add Central Package Management (CPM)
Enable Treat Warnings As Errors
Removed ExportTodos feature to simplify the template.
</releaseNotes>

<projectUrl>https://github.com/JasonTaylorDev/CleanArchitecture</projectUrl>
Expand Down
1 change: 0 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
<PackageVersion Include="Ardalis.GuardClauses" Version="4.0.1" />
<PackageVersion Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
<PackageVersion Include="CsvHelper" Version="30.0.1" />
<PackageVersion Include="FluentAssertions" Version="6.11.0" />
<PackageVersion Include="FluentValidation.AspNetCore" Version="11.3.0" />
<PackageVersion Include="FluentValidation.DependencyInjectionExtensions" Version="11.5.2" />
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The template depends on the latest versions of:

The easiest way to get started is to install the [.NET template](https://www.nuget.org/packages/Clean.Architecture.Solution.Template):
```
dotnet new install Clean.Architecture.Solution.Template::8.0.0-preview.5.7
dotnet new install Clean.Architecture.Solution.Template::8.0.0-preview.5.10
```

Once installed, create a new solution using the template. You can choose to use Angular, React, or create a Web API-only solution. Specify the client framework using the `-cf` or `--client-framework` option, and provide the output directory where your project will be created. Here are some examples:
Expand Down
8 changes: 0 additions & 8 deletions src/Application/Common/Interfaces/ICsvFileBuilder.cs

This file was deleted.

37 changes: 0 additions & 37 deletions src/Application/TodoLists/Queries/ExportTodos/ExportTodos.cs

This file was deleted.

17 changes: 0 additions & 17 deletions src/Application/TodoLists/Queries/ExportTodos/ExportTodosVm.cs

This file was deleted.

18 changes: 0 additions & 18 deletions src/Application/TodoLists/Queries/ExportTodos/TodoItemRecord.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/Infrastructure/ConfigureServices.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CleanArchitecture.Application.Common.Interfaces;
using CleanArchitecture.Infrastructure.Data;
using CleanArchitecture.Infrastructure.Data.Interceptors;
using CleanArchitecture.Infrastructure.Files;
using CleanArchitecture.Infrastructure.Identity;
using CleanArchitecture.Infrastructure.Services;
using Microsoft.AspNetCore.Identity;
Expand Down Expand Up @@ -38,7 +37,6 @@ public static IServiceCollection AddInfrastructureServices(this IServiceCollecti

services.AddTransient<IDateTime, DateTimeService>();
services.AddTransient<IIdentityService, IdentityService>();
services.AddTransient<ICsvFileBuilder, CsvFileBuilder>();

services.AddAuthorization(options =>
options.AddPolicy("CanPurge", policy => policy.RequireRole("Administrator")));
Expand Down
24 changes: 0 additions & 24 deletions src/Infrastructure/Files/CsvFileBuilder.cs

This file was deleted.

15 changes: 0 additions & 15 deletions src/Infrastructure/Files/Maps/TodoItemRecordMap.cs

This file was deleted.

1 change: 0 additions & 1 deletion src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
</ItemGroup>
<!--#endif-->
<ItemGroup>
<PackageReference Include="CsvHelper" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" />
Expand Down
48 changes: 0 additions & 48 deletions src/WebUI/ClientApp/src/app/web-api-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,6 @@ export class TodoItemsClient implements ITodoItemsClient {
export interface ITodoListsClient {
getTodoLists(): Observable<TodosVm>;
createTodoList(command: CreateTodoListCommand): Observable<number>;
exportTodos(id: number): Observable<void>;
updateTodoList(id: number, command: UpdateTodoListCommand): Observable<void>;
deleteTodoList(id: number): Observable<void>;
}
Expand Down Expand Up @@ -421,53 +420,6 @@ export class TodoListsClient implements ITodoListsClient {
return _observableOf(null as any);
}

exportTodos(id: number): Observable<void> {
let url_ = this.baseUrl + "/api/TodoLists/Export/{id}";
if (id === undefined || id === null)
throw new Error("The parameter 'id' must be defined.");
url_ = url_.replace("{id}", encodeURIComponent("" + id));
url_ = url_.replace(/[?&]$/, "");

let options_ : any = {
observe: "response",
responseType: "blob",
headers: new HttpHeaders({
})
};

return this.http.request("get", url_, options_).pipe(_observableMergeMap((response_ : any) => {
return this.processExportTodos(response_);
})).pipe(_observableCatch((response_: any) => {
if (response_ instanceof HttpResponseBase) {
try {
return this.processExportTodos(response_ as any);
} catch (e) {
return _observableThrow(e) as any as Observable<void>;
}
} else
return _observableThrow(response_) as any as Observable<void>;
}));
}

protected processExportTodos(response: HttpResponseBase): Observable<void> {
const status = response.status;
const responseBlob =
response instanceof HttpResponse ? response.body :
(response as any).error instanceof Blob ? (response as any).error : undefined;

let _headers: any = {}; if (response.headers) { for (let key of response.headers.keys()) { _headers[key] = response.headers.get(key); }}
if (status === 200) {
return blobToText(responseBlob).pipe(_observableMergeMap((_responseText: string) => {
return _observableOf(null as any);
}));
} else if (status !== 200 && status !== 204) {
return blobToText(responseBlob).pipe(_observableMergeMap((_responseText: string) => {
return throwException("An unexpected server error occurred.", status, _responseText, _headers);
}));
}
return _observableOf(null as any);
}

updateTodoList(id: number, command: UpdateTodoListCommand): Observable<void> {
let url_ = this.baseUrl + "/api/TodoLists/{id}";
if (id === undefined || id === null)
Expand Down
8 changes: 0 additions & 8 deletions src/WebUI/Endpoints/TodoLists.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using CleanArchitecture.Application.TodoLists.Commands.CreateTodoList;
using CleanArchitecture.Application.TodoLists.Commands.DeleteTodoList;
using CleanArchitecture.Application.TodoLists.Commands.UpdateTodoList;
using CleanArchitecture.Application.TodoLists.Queries.ExportTodos;
using CleanArchitecture.Application.TodoLists.Queries.GetTodos;

namespace CleanArchitecture.WebUI.Endpoints;
Expand All @@ -13,7 +12,6 @@ public override void Map(WebApplication app)
app.MapGroup(this)
.RequireAuthorization()
.MapGet(GetTodoLists)
.MapGet(ExportTodos, "Export/{id}")
.MapPost(CreateTodoList)
.MapPut(UpdateTodoList, "{id}")
.MapDelete(DeleteTodoList, "{id}");
Expand All @@ -24,12 +22,6 @@ public async Task<TodosVm> GetTodoLists(ISender sender)
return await sender.Send(new GetTodosQuery());
}

public async Task<IResult> ExportTodos(ISender sender, int id)
{
var vm = await sender.Send(new ExportTodosQuery { ListId = id });
return Results.File(vm.Content, vm.ContentType, vm.FileName);
}

public async Task<int> CreateTodoList(ISender sender, CreateTodoListCommand command)
{
return await sender.Send(command);
Expand Down
25 changes: 0 additions & 25 deletions src/WebUI/wwwroot/api/specification.json
Original file line number Diff line number Diff line change
Expand Up @@ -241,31 +241,6 @@
}
}
},
"/api/TodoLists/Export/{id}": {
"get": {
"tags": [
"TodoLists"
],
"operationId": "ExportTodos",
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer",
"format": "int32"
},
"x-position": 1
}
],
"responses": {
"200": {
"description": ""
}
}
}
},
"/api/TodoLists/{id}": {
"put": {
"tags": [
Expand Down
2 changes: 0 additions & 2 deletions tests/Application.UnitTests/Common/Mappings/MappingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using CleanArchitecture.Application.Common.Interfaces;
using CleanArchitecture.Application.Common.Models;
using CleanArchitecture.Application.TodoItems.Queries.GetTodoItemsWithPagination;
using CleanArchitecture.Application.TodoLists.Queries.ExportTodos;
using CleanArchitecture.Application.TodoLists.Queries.GetTodos;
using CleanArchitecture.Domain.Entities;
using NUnit.Framework;
Expand Down Expand Up @@ -35,7 +34,6 @@ public void ShouldHaveValidConfiguration()
[TestCase(typeof(TodoItem), typeof(TodoItemDto))]
[TestCase(typeof(TodoList), typeof(LookupDto))]
[TestCase(typeof(TodoItem), typeof(LookupDto))]
[TestCase(typeof(TodoItem), typeof(TodoItemRecord))]
[TestCase(typeof(TodoItem), typeof(TodoItemBriefDto))]
public void ShouldSupportMappingFromSourceToDestination(Type source, Type destination)
{
Expand Down

0 comments on commit f791b65

Please sign in to comment.