source: ChapterX.Application/AISuggestion/Commands/AddHandler.cs@ e882b92

main
Last change on this file since e882b92 was e882b92, checked in by kikisrbinoska <srbinoskakristina07@…>, 13 days ago

Added corrected entitef from the ER diagram and changes for the logic to be coresponding to the ddl

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[877c13c]1using ChapterX.Domain.Repositories;
2using MediatR;
3using Microsoft.Extensions.Logging;
4
5namespace ChapterX.Application.AISuggestion.Commands
6{
7 public class AddHandler : IRequestHandler<AddRequest, AddResponse>
8 {
9 private readonly IAISuggestionRepository _aiSuggestionRepository;
10 private readonly ILogger<AddHandler> _logger;
11
12 public AddHandler(IAISuggestionRepository aiSuggestionRepository, ILogger<AddHandler> logger)
13 {
14 _aiSuggestionRepository = aiSuggestionRepository;
15 _logger = logger;
16 }
17
18 public async Task<AddResponse> Handle(AddRequest request, CancellationToken cancellationToken)
19 {
20 var suggestion = new Domain.Entities.AISuggestion
21 {
22 OriginalText = request.OriginalText,
23 SuggestedText = request.SuggestedText,
[e882b92]24 SuggestionType = request.SuggestionType,
[877c13c]25 StoryId = request.StoryId,
[b62cefc]26 Accepted = null,
[877c13c]27 CreatedAt = DateTime.UtcNow
28 };
29
30 await _aiSuggestionRepository.AddAsync(suggestion, cancellationToken);
31
32 return new AddResponse(suggestion.Id);
33 }
34 }
35}
Note: See TracBrowser for help on using the repository browser.