Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

CommentService.cs 1.1KB

123456789101112131415161718192021222324252627282930
  1. namespace Diligent.WebAPI.Business.Services
  2. {
  3. public class CommentService : ICommentService
  4. {
  5. private readonly DatabaseContext _context;
  6. private readonly IMapper _mapper;
  7. private readonly ILogger<CommentService> _logger;
  8. public CommentService(DatabaseContext context, IMapper mapper, ILogger<CommentService> logger)
  9. {
  10. _context = context;
  11. _mapper = mapper;
  12. _logger = logger;
  13. }
  14. public async Task CreateComment(CommentCreateDto commentCreateDto)
  15. {
  16. _logger.LogInformation("Start creating comment");
  17. var comment = _mapper.Map<Comment>(commentCreateDto);
  18. comment.DateOfSending = DateTime.Now;
  19. _logger.LogInformation($"Comment created successfully in {comment.DateOfSending}");
  20. _logger.LogInformation($"Saving comment in Db");
  21. await _context.Comments.AddAsync(comment);
  22. var result = _context.SaveChangesAsync();
  23. _logger.LogInformation($"Comment saved in Db");
  24. await result;
  25. }
  26. }
  27. }