Skip to content

Commit d5fd426

Browse files
fix: compile errors
1 parent 3666090 commit d5fd426

17 files changed

Lines changed: 96 additions & 77 deletions
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using System.ComponentModel.DataAnnotations;
22
using CanBeYours.Core.Resources;
3-
using CodeBlock.DevKit.Contracts.Dtos;
43

54
namespace CanBeYours.Application.Dtos;
65

7-
public class CreateDemoThingDto : BaseDto
6+
public class CreateDemoThingDto
87
{
98
[Required(ErrorMessageResourceType = typeof(SharedResource), ErrorMessageResourceName = nameof(SharedResource.DemoThing_Name))]
109
public string Name { get; set; }
1110

1211
[Required(ErrorMessageResourceType = typeof(SharedResource), ErrorMessageResourceName = nameof(SharedResource.DemoThing_Description))]
1312
public string Description { get; set; }
14-
}
13+
}

src/1-Libraries/Application/Dtos/GetDemoThingDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace CanBeYours.Application.Dtos;
44

5-
public class GetDemoThingDto : BaseDto
5+
public class GetDemoThingDto : GetEntityDto
66
{
77
public string Name { get; set; }
88
public string Description { get; set; }

src/1-Libraries/Application/Dtos/SearchDemoThingsInputDto.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ namespace CanBeYours.Application.Dtos;
55
public class SearchDemoThingsInputDto : SearchInputDto
66
{
77
// Add any additional search filters here if needed in the future
8-
}
8+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
using System.ComponentModel.DataAnnotations;
22
using CanBeYours.Core.Resources;
3-
using CodeBlock.DevKit.Contracts.Dtos;
43

54
namespace CanBeYours.Application.Dtos;
65

7-
public class UpdateDemoThingDto : BaseDto
6+
public class UpdateDemoThingDto
87
{
98
[Required(ErrorMessageResourceType = typeof(SharedResource), ErrorMessageResourceName = nameof(SharedResource.DemoThing_Name))]
109
public string Name { get; set; }
1110

1211
[Required(ErrorMessageResourceType = typeof(SharedResource), ErrorMessageResourceName = nameof(SharedResource.DemoThing_Description))]
1312
public string Description { get; set; }
14-
}
13+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// Copyright (c) CodeBlock.Dev. All rights reserved.
2+
// For more information visit https://codeblock.dev
3+
4+
using CanBeYours.Core.Resources;
5+
using CodeBlock.DevKit.Core.Exceptions;
6+
using CodeBlock.DevKit.Core.Resources;
7+
using ApplicationException = CodeBlock.DevKit.Application.Exceptions.ApplicationException;
8+
9+
namespace CanBeYours.Application.Exceptions;
10+
11+
internal static class DemoThingApplicationExceptions
12+
{
13+
public static ApplicationException DemoThingNotFound(string searchedKey)
14+
{
15+
return new ApplicationException(
16+
nameof(CoreResource.Record_Not_Found),
17+
typeof(CoreResource),
18+
new List<MessagePlaceholder>
19+
{
20+
MessagePlaceholder.CreateResource(SharedResource.DemoThing, typeof(SharedResource)),
21+
MessagePlaceholder.CreatePlainText(searchedKey),
22+
}
23+
);
24+
}
25+
}

src/1-Libraries/Application/Services/DemoThings/DemoThingService.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ public async Task<Result<CommandResult>> UpdateDemoThing(string id, UpdateDemoTh
3131

3232
public async Task<Result<SearchOutputDto<GetDemoThingDto>>> SearchDemoThings(SearchDemoThingsInputDto input)
3333
{
34-
return await _requestDispatcher.SendQuery(
35-
new SearchDemoThingsRequest(input.Term, input.PageNumber, input.RecordsPerPage, input.SortOrder)
36-
);
34+
return await _requestDispatcher.SendQuery(new SearchDemoThingsRequest(input.Term, input.PageNumber, input.RecordsPerPage, input.SortOrder));
3735
}
3836
}

src/1-Libraries/Application/UseCases/DemoThings/CreateDemoThing/CreateDemoThingRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ public CreateDemoThingRequest(string name, string description)
2020
[Display(Name = nameof(SharedResource.DemoThing_Description), ResourceType = typeof(SharedResource))]
2121
[Required(ErrorMessageResourceName = nameof(CoreResource.Required), ErrorMessageResourceType = typeof(CoreResource))]
2222
public string Description { get; }
23-
}
23+
}

src/1-Libraries/Application/UseCases/DemoThings/CreateDemoThing/CreateDemoThingUseCase.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ internal class CreateDemoThingUseCase : BaseCommandHandler, IRequestHandler<Crea
1111
{
1212
private readonly IDemoThingRepository _demoThingRepository;
1313

14-
public CreateDemoThingUseCase(IDemoThingRepository demoThingRepository, IRequestDispatcher requestDispatcher, ILogger<CreateDemoThingUseCase> logger)
14+
public CreateDemoThingUseCase(
15+
IDemoThingRepository demoThingRepository,
16+
IRequestDispatcher requestDispatcher,
17+
ILogger<CreateDemoThingUseCase> logger
18+
)
1519
: base(requestDispatcher, logger)
1620
{
1721
_demoThingRepository = demoThingRepository;
@@ -27,4 +31,4 @@ public async Task<CommandResult> Handle(CreateDemoThingRequest request, Cancella
2731

2832
return CommandResult.Create(entityId: demoThing.Id);
2933
}
30-
}
34+
}
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
using CanBeYours.Application.Dtos;
22
using CodeBlock.DevKit.Application.Queries;
3+
using CodeBlock.DevKit.Core.Helpers;
34

45
namespace CanBeYours.Application.UseCases.DemoThings.GetDemoThing;
56

67
internal class GetDemoThingRequest : BaseQuery<GetDemoThingDto>
78
{
8-
public GetDemoThingRequest(string id)
9+
public GetDemoThingRequest(string id, QueryOptions options = null)
10+
: base(options)
911
{
1012
Id = id;
1113
}
1214

13-
public string Id { get; }
14-
}
15+
public string Id { get; set; }
16+
}
Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,29 @@
1+
using AutoMapper;
12
using CanBeYours.Application.Dtos;
3+
using CanBeYours.Application.Exceptions;
24
using CanBeYours.Core.Domain.DemoThings;
35
using CodeBlock.DevKit.Application.Queries;
4-
using CodeBlock.DevKit.Application.Srvices;
5-
using CodeBlock.DevKit.Core.Helpers;
66
using MediatR;
77
using Microsoft.Extensions.Logging;
88

99
namespace CanBeYours.Application.UseCases.DemoThings.GetDemoThing;
1010

11-
internal class GetDemoThingUseCase : BaseQueryHandler, IRequestHandler<GetDemoThingRequest, Result<GetDemoThingDto>>
11+
internal class GetDemoThingUseCase : BaseQueryHandler, IRequestHandler<GetDemoThingRequest, GetDemoThingDto>
1212
{
1313
private readonly IDemoThingRepository _demoThingRepository;
1414

15-
public GetDemoThingUseCase(IDemoThingRepository demoThingRepository, IRequestDispatcher requestDispatcher, ILogger<GetDemoThingUseCase> logger)
16-
: base(requestDispatcher, logger)
15+
public GetDemoThingUseCase(IDemoThingRepository demoThingRepository, IMapper mapper, ILogger<GetDemoThingUseCase> logger)
16+
: base(mapper, logger)
1717
{
1818
_demoThingRepository = demoThingRepository;
1919
}
2020

21-
public async Task<Result<GetDemoThingDto>> Handle(GetDemoThingRequest request, CancellationToken cancellationToken)
21+
public async Task<GetDemoThingDto> Handle(GetDemoThingRequest request, CancellationToken cancellationToken)
2222
{
2323
var demoThing = await _demoThingRepository.GetByIdAsync(request.Id);
2424
if (demoThing == null)
25-
return Result<GetDemoThingDto>.NotFound();
25+
throw DemoThingApplicationExceptions.DemoThingNotFound(request.Id);
2626

27-
return Result<GetDemoThingDto>.Success(MapToDto(demoThing));
27+
return _mapper.Map<GetDemoThingDto>(demoThing);
2828
}
29-
30-
private static GetDemoThingDto MapToDto(DemoThing demoThing)
31-
{
32-
return new GetDemoThingDto
33-
{
34-
Id = demoThing.Id,
35-
Name = demoThing.Name,
36-
Description = demoThing.Description,
37-
CreationTime = demoThing.CreationTime
38-
};
39-
}
40-
}
29+
}

0 commit comments

Comments
 (0)