Skip to content

Commit e6ec75c

Browse files
committed
chore: implement file scoped
1 parent d9ccc49 commit e6ec75c

File tree

110 files changed

+1950
-2062
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

110 files changed

+1950
-2062
lines changed
Lines changed: 37 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,47 @@
1-
using CleanArch.Application.Contracts.Persistence;
1+
using CleanArch.Application.Contracts.Persistence;
22
using CleanArch.Domain.Services.Authentication;
33
using Microsoft.AspNetCore.Mvc;
44
using System.Threading.Tasks;
55

6-
namespace CleanArch.Api.Account
6+
namespace CleanArch.Api.Account;
7+
8+
[Route("api/[controller]")]
9+
[ApiController]
10+
public class AccountController : ControllerBase
711
{
8-
[Route("api/[controller]")]
9-
[ApiController]
10-
public class AccountController : ControllerBase
12+
private readonly IAuthenticationService _authenticationService;
13+
public AccountController(IAuthenticationService authenticationService)
1114
{
12-
private readonly IAuthenticationService _authenticationService;
13-
public AccountController(IAuthenticationService authenticationService)
14-
{
15-
_authenticationService = authenticationService;
16-
}
17-
18-
[HttpPost("authenticate")]
19-
public async Task<IActionResult> AuthenticateAsync(AuthenticationRequest request)
20-
{
21-
return Ok(await _authenticationService.AuthenticateAsync(request));
22-
}
23-
[HttpPost("register")]
24-
public async Task<IActionResult> RegisterAsync(RegistrationRequest request)
25-
{
26-
var origin = Request.Headers["origin"];
27-
return Ok(await _authenticationService.RegisterAsync(request, origin));
28-
}
29-
[HttpGet("confirm-email")]
30-
public async Task<IActionResult> ConfirmEmailAsync([FromQuery] string userId, [FromQuery] string code)
31-
{
32-
return Ok(await _authenticationService.ConfirmEmailAsync(userId, code));
33-
}
34-
[HttpPost("forgot-password")]
35-
public async Task<IActionResult> ForgotPassword(ForgotPasswordRequest model)
36-
{
37-
await _authenticationService.ForgotPassword(model, Request.Headers["origin"]);
38-
return Ok();
39-
}
40-
[HttpPost("reset-password")]
41-
public async Task<IActionResult> ResetPassword(ResetPasswordRequest model)
42-
{
15+
_authenticationService = authenticationService;
16+
}
4317

44-
return Ok(await _authenticationService.ResetPassword(model));
45-
}
18+
[HttpPost("authenticate")]
19+
public async Task<IActionResult> AuthenticateAsync(AuthenticationRequest request)
20+
{
21+
return Ok(await _authenticationService.AuthenticateAsync(request));
22+
}
23+
[HttpPost("register")]
24+
public async Task<IActionResult> RegisterAsync(RegistrationRequest request)
25+
{
26+
var origin = Request.Headers["origin"];
27+
return Ok(await _authenticationService.RegisterAsync(request, origin));
28+
}
29+
[HttpGet("confirm-email")]
30+
public async Task<IActionResult> ConfirmEmailAsync([FromQuery] string userId, [FromQuery] string code)
31+
{
32+
return Ok(await _authenticationService.ConfirmEmailAsync(userId, code));
33+
}
34+
[HttpPost("forgot-password")]
35+
public async Task<IActionResult> ForgotPassword(ForgotPasswordRequest model)
36+
{
37+
await _authenticationService.ForgotPassword(model, Request.Headers["origin"]);
38+
return Ok();
39+
}
40+
[HttpPost("reset-password")]
41+
public async Task<IActionResult> ResetPassword(ResetPasswordRequest model)
42+
{
4643

44+
return Ok(await _authenticationService.ResetPassword(model));
4745
}
46+
4847
}
Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CleanArch.Api.Controllers;
1+
using CleanArch.Api.Controllers;
22
using CleanArch.Application.Features.Categories.Commands.CreateCategory;
33
using CleanArch.Application.Features.Categories.Queries.GetCategoriesList;
44
using CleanArch.Application.Features.Categories.Queries.GetCategoriesListWithEvents;
@@ -8,37 +8,36 @@
88
using System.Collections.Generic;
99
using System.Threading.Tasks;
1010

11-
namespace CleanArch.Api.Category.v1
11+
namespace CleanArch.Api.Category.v1;
12+
13+
public class CategoryController : BaseController
1214
{
13-
public class CategoryController : BaseController
14-
{
1515

16-
[HttpGet("all", Name = "GetAllCategories")]
17-
[ProducesResponseType(StatusCodes.Status200OK)]
18-
public async Task<ActionResult<List<CategoryListVm>>> GetAllCategories()
19-
{
20-
var dtos = await Mediator.Send(new GetCategoriesListQuery());
21-
return Ok(dtos);
22-
}
16+
[HttpGet("all", Name = "GetAllCategories")]
17+
[ProducesResponseType(StatusCodes.Status200OK)]
18+
public async Task<ActionResult<List<CategoryListVm>>> GetAllCategories()
19+
{
20+
var dtos = await Mediator.Send(new GetCategoriesListQuery());
21+
return Ok(dtos);
22+
}
2323

24-
[Authorize]
25-
[HttpGet("allwithevents", Name = "GetCategoriesWithEvents")]
26-
[ProducesDefaultResponseType]
27-
[ProducesResponseType(StatusCodes.Status200OK)]
28-
public async Task<ActionResult<List<CategoryEventListVm>>> GetCategoriesWithEvents(bool includeHistory)
29-
{
30-
GetCategoriesListWithEventsQuery getCategoriesListWithEventsQuery = new GetCategoriesListWithEventsQuery() { IncludeHistory = includeHistory };
24+
[Authorize]
25+
[HttpGet("allwithevents", Name = "GetCategoriesWithEvents")]
26+
[ProducesDefaultResponseType]
27+
[ProducesResponseType(StatusCodes.Status200OK)]
28+
public async Task<ActionResult<List<CategoryEventListVm>>> GetCategoriesWithEvents(bool includeHistory)
29+
{
30+
GetCategoriesListWithEventsQuery getCategoriesListWithEventsQuery = new GetCategoriesListWithEventsQuery() { IncludeHistory = includeHistory };
3131

32-
var dtos = await Mediator.Send(getCategoriesListWithEventsQuery);
33-
return Ok(dtos);
34-
}
32+
var dtos = await Mediator.Send(getCategoriesListWithEventsQuery);
33+
return Ok(dtos);
34+
}
3535

36-
[Authorize]
37-
[HttpPost(Name = "AddCategory")]
38-
public async Task<ActionResult<CreateCategoryCommandResponse>> Create([FromBody] CreateCategoryCommand createCategoryCommand)
39-
{
40-
var response = await Mediator.Send(createCategoryCommand);
41-
return Ok(response);
42-
}
36+
[Authorize]
37+
[HttpPost(Name = "AddCategory")]
38+
public async Task<ActionResult<CreateCategoryCommandResponse>> Create([FromBody] CreateCategoryCommand createCategoryCommand)
39+
{
40+
var response = await Mediator.Send(createCategoryCommand);
41+
return Ok(response);
4342
}
44-
}
43+
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
using MediatR;
1+
using MediatR;
22
using Microsoft.AspNetCore.Authorization;
33
using Microsoft.AspNetCore.Mvc;
44
using Microsoft.Extensions.DependencyInjection;
55

6-
namespace CleanArch.Api.Controllers
6+
namespace CleanArch.Api.Controllers;
7+
8+
[Authorize]
9+
[ApiController]
10+
[Route("api/v{version:apiVersion}/[controller]")]
11+
[ApiVersion("1.0")]
12+
public class BaseController : ControllerBase
713
{
8-
[Authorize]
9-
[ApiController]
10-
[Route("api/v{version:apiVersion}/[controller]")]
11-
[ApiVersion("1.0")]
12-
public class BaseController : ControllerBase
13-
{
14-
private IMediator _mediator;
14+
private IMediator _mediator;
1515

16-
protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService<IMediator>();
17-
}
18-
}
16+
protected IMediator Mediator => _mediator ??= HttpContext.RequestServices.GetService<IMediator>();
17+
}
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
1-
using Microsoft.AspNetCore.Mvc;
1+
using Microsoft.AspNetCore.Mvc;
22
using System.Diagnostics;
33

4-
namespace CleanArch.Api.Controllers
4+
namespace CleanArch.Api.Controllers;
5+
6+
public class MetaController : ControllerBase
57
{
6-
public class MetaController : ControllerBase
8+
[HttpGet("/info")]
9+
public ActionResult<string> Info()
710
{
8-
[HttpGet("/info")]
9-
public ActionResult<string> Info()
10-
{
11-
var assembly = typeof(Startup).Assembly;
11+
var assembly = typeof(Startup).Assembly;
1212

13-
var lastUpdate = System.IO.File.GetLastWriteTime(assembly.Location);
14-
var version = FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
13+
var lastUpdate = System.IO.File.GetLastWriteTime(assembly.Location);
14+
var version = FileVersionInfo.GetVersionInfo(assembly.Location).ProductVersion;
1515

16-
return Ok($"Version: {version}, Last Updated: {lastUpdate}");
17-
}
16+
return Ok($"Version: {version}, Last Updated: {lastUpdate}");
1817
}
19-
}
18+
}
Lines changed: 54 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using CleanArch.Api.Controllers;
1+
using CleanArch.Api.Controllers;
22
using CleanArch.Application.Features.Events.Commands.CreateEvent;
33
using CleanArch.Application.Features.Events.Commands.DeleteEvent;
44
using CleanArch.Application.Features.Events.Commands.UpdateEvent;
@@ -12,67 +12,66 @@
1212
using System;
1313
using System.Threading.Tasks;
1414

15-
namespace CleanArch.Api.Event.v1
15+
namespace CleanArch.Api.Event.v1;
16+
17+
public class EventsController : BaseController
1618
{
17-
public class EventsController : BaseController
19+
[HttpGet(Name = "GetAllEvents")]
20+
[ProducesResponseType(StatusCodes.Status200OK)]
21+
[ProducesDefaultResponseType]
22+
public async Task<IActionResult> GetAll()
1823
{
19-
[HttpGet(Name = "GetAllEvents")]
20-
[ProducesResponseType(StatusCodes.Status200OK)]
21-
[ProducesDefaultResponseType]
22-
public async Task<IActionResult> GetAll()
23-
{
24-
var vm = await Mediator.Send(new GetEventsListQuery());
25-
return Ok(vm);
26-
}
27-
28-
[Authorize]
29-
[HttpGet("{id}", Name = "GetEventById")]
30-
public async Task<IActionResult> GetEventById(Guid id)
31-
{
32-
var getEventDetailQuery = new GetEventDetailQuery() { Id = id };
33-
return Ok(await Mediator.Send(getEventDetailQuery));
34-
}
24+
var vm = await Mediator.Send(new GetEventsListQuery());
25+
return Ok(vm);
26+
}
3527

36-
[Authorize]
37-
[HttpPost(Name = "AddEvent")]
38-
public async Task<ActionResult<Guid>> Create([FromBody] CreateEventCommand createEventCommand)
39-
{
40-
var id = await Mediator.Send(createEventCommand);
41-
return Ok(id);
42-
}
28+
[Authorize]
29+
[HttpGet("{id}", Name = "GetEventById")]
30+
public async Task<IActionResult> GetEventById(Guid id)
31+
{
32+
var getEventDetailQuery = new GetEventDetailQuery() { Id = id };
33+
return Ok(await Mediator.Send(getEventDetailQuery));
34+
}
4335

44-
[Authorize]
45-
[HttpPut(Name = "UpdateEvent")]
46-
[ProducesResponseType(StatusCodes.Status204NoContent)]
47-
[ProducesResponseType(StatusCodes.Status404NotFound)]
48-
[ProducesDefaultResponseType]
49-
public async Task<ActionResult> Update([FromBody] UpdateEventCommand updateEventCommand)
50-
{
51-
await Mediator.Send(updateEventCommand);
52-
return NoContent();
53-
}
36+
[Authorize]
37+
[HttpPost(Name = "AddEvent")]
38+
public async Task<ActionResult<Guid>> Create([FromBody] CreateEventCommand createEventCommand)
39+
{
40+
var id = await Mediator.Send(createEventCommand);
41+
return Ok(id);
42+
}
5443

55-
[Authorize]
56-
[HttpDelete("{id}", Name = "DeleteEvent")]
57-
[ProducesResponseType(StatusCodes.Status204NoContent)]
58-
[ProducesResponseType(StatusCodes.Status404NotFound)]
59-
[ProducesDefaultResponseType]
60-
public async Task<ActionResult> Delete(Guid id)
61-
{
62-
var deleteEventCommand = new DeleteEventCommand() { EventId = id };
63-
await Mediator.Send(deleteEventCommand);
64-
return NoContent();
65-
}
44+
[Authorize]
45+
[HttpPut(Name = "UpdateEvent")]
46+
[ProducesResponseType(StatusCodes.Status204NoContent)]
47+
[ProducesResponseType(StatusCodes.Status404NotFound)]
48+
[ProducesDefaultResponseType]
49+
public async Task<ActionResult> Update([FromBody] UpdateEventCommand updateEventCommand)
50+
{
51+
await Mediator.Send(updateEventCommand);
52+
return NoContent();
53+
}
6654

67-
[Authorize]
68-
[HttpGet("export", Name = "ExportEvents")]
69-
[FileResultContentType("text/csv")]
70-
public async Task<FileResult> ExportEvents()
71-
{
72-
var fileDto = await Mediator.Send(new GetEventsExportQuery());
55+
[Authorize]
56+
[HttpDelete("{id}", Name = "DeleteEvent")]
57+
[ProducesResponseType(StatusCodes.Status204NoContent)]
58+
[ProducesResponseType(StatusCodes.Status404NotFound)]
59+
[ProducesDefaultResponseType]
60+
public async Task<ActionResult> Delete(Guid id)
61+
{
62+
var deleteEventCommand = new DeleteEventCommand() { EventId = id };
63+
await Mediator.Send(deleteEventCommand);
64+
return NoContent();
65+
}
7366

74-
return File(fileDto.Data, fileDto.ContentType, fileDto.EventExportFileName);
75-
}
67+
[Authorize]
68+
[HttpGet("export", Name = "ExportEvents")]
69+
[FileResultContentType("text/csv")]
70+
public async Task<FileResult> ExportEvents()
71+
{
72+
var fileDto = await Mediator.Send(new GetEventsExportQuery());
7673

74+
return File(fileDto.Data, fileDto.ContentType, fileDto.EventExportFileName);
7775
}
76+
7877
}

0 commit comments

Comments
 (0)