From 8c6494f9ec025b2031252ac41938f01b8d4eef6f Mon Sep 17 00:00:00 2001 From: Eric <36512385+PhucNghi176@users.noreply.github.com> Date: Thu, 24 Oct 2024 22:52:59 +0700 Subject: [PATCH] Update --- .../MBS_COMMAND.Application.csproj | 2 +- .../Feedbacks/CreateFeedbackCommandHandler.cs | 22 +++++++------------ MBS_COMMAND.Domain/Entities/User.cs | 3 +-- MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj | 2 +- 4 files changed, 11 insertions(+), 18 deletions(-) diff --git a/MBS_COMMAND.Application/MBS_COMMAND.Application.csproj b/MBS_COMMAND.Application/MBS_COMMAND.Application.csproj index f6240ea..cf2dd1e 100644 --- a/MBS_COMMAND.Application/MBS_COMMAND.Application.csproj +++ b/MBS_COMMAND.Application/MBS_COMMAND.Application.csproj @@ -16,7 +16,7 @@ - + diff --git a/MBS_COMMAND.Application/UserCases/Commands/Feedbacks/CreateFeedbackCommandHandler.cs b/MBS_COMMAND.Application/UserCases/Commands/Feedbacks/CreateFeedbackCommandHandler.cs index b93767a..6361179 100644 --- a/MBS_COMMAND.Application/UserCases/Commands/Feedbacks/CreateFeedbackCommandHandler.cs +++ b/MBS_COMMAND.Application/UserCases/Commands/Feedbacks/CreateFeedbackCommandHandler.cs @@ -7,21 +7,15 @@ namespace MBS_COMMAND.Application.UserCases.Commands.Feedbacks; -public class CreateFeedbackCommandHandler : ICommandHandler +public class CreateFeedbackCommandHandler( + IRepositoryBase feedbackRepository, + ICurrentUserService currentUserService, + IUnitOfWork unitOfWork) + : ICommandHandler { - private readonly IRepositoryBase _feedbackRepository; - private readonly ICurrentUserService _currentUserService; - private readonly IUnitOfWork _unitOfWork; - public CreateFeedbackCommandHandler(IRepositoryBase feedbackRepository, ICurrentUserService currentUserService, IUnitOfWork unitOfWork) - { - _feedbackRepository = feedbackRepository; - _currentUserService = currentUserService; - _unitOfWork = unitOfWork; - } - public async Task Handle(Command.CreateFeedback request, CancellationToken cancellationToken) { - var role = _currentUserService.Role == "1"; + var role = currentUserService.Role == "1"; var feedback = new Feedback { Content = request.Content, @@ -30,8 +24,8 @@ public async Task Handle(Command.CreateFeedback request, CancellationTok ScheduleId = request.ScheduleId, IsMentor = role, }; - _feedbackRepository.Add(feedback); - await _unitOfWork.SaveChangesAsync(cancellationToken); + feedbackRepository.Add(feedback); + await unitOfWork.SaveChangesAsync(cancellationToken); return Result.Success(); } } \ No newline at end of file diff --git a/MBS_COMMAND.Domain/Entities/User.cs b/MBS_COMMAND.Domain/Entities/User.cs index 5f87e3d..d11825c 100644 --- a/MBS_COMMAND.Domain/Entities/User.cs +++ b/MBS_COMMAND.Domain/Entities/User.cs @@ -33,6 +33,7 @@ public void CreateSlot(IEnumerable slots) { var slot = slots.Select(x => new DomainEvent.Slot { + SlotId = x.Id, MentorId = x.MentorId, StartTime = x.StartTime, EndTime = x.EndTime, @@ -43,7 +44,5 @@ public void CreateSlot(IEnumerable slots) IsBook = x.IsBook, }).ToList(); RaiseDomainEvent(new DomainEvent.MentorSlotCreated(Guid.NewGuid(), slot)); - Console.BackgroundColor = ConsoleColor.DarkGreen; - Console.WriteLine("MentorSlotCreatedDomainevent"); } } \ No newline at end of file diff --git a/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj b/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj index 05cd798..52ff600 100644 --- a/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj +++ b/MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj @@ -11,7 +11,7 @@ - +