Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
PhucNghi176 committed Oct 24, 2024
1 parent 428e46e commit 8c6494f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion MBS_COMMAND.Application/MBS_COMMAND.Application.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="FluentValidation" Version="11.10.0" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.10.0" />
<PackageReference Include="MBS_CONTRACT.SHARE" Version="1.1.12" />
<PackageReference Include="MBS_CONTRACT.SHARE" Version="1.1.14" />
<PackageReference Include="MediatR" Version="12.4.1" />
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,15 @@

namespace MBS_COMMAND.Application.UserCases.Commands.Feedbacks;

public class CreateFeedbackCommandHandler : ICommandHandler<Command.CreateFeedback>
public class CreateFeedbackCommandHandler(
IRepositoryBase<Feedback, Guid> feedbackRepository,
ICurrentUserService currentUserService,
IUnitOfWork unitOfWork)
: ICommandHandler<Command.CreateFeedback>
{
private readonly IRepositoryBase<Feedback, Guid> _feedbackRepository;
private readonly ICurrentUserService _currentUserService;
private readonly IUnitOfWork _unitOfWork;
public CreateFeedbackCommandHandler(IRepositoryBase<Feedback, Guid> feedbackRepository, ICurrentUserService currentUserService, IUnitOfWork unitOfWork)
{
_feedbackRepository = feedbackRepository;
_currentUserService = currentUserService;
_unitOfWork = unitOfWork;
}

public async Task<Result> Handle(Command.CreateFeedback request, CancellationToken cancellationToken)
{
var role = _currentUserService.Role == "1";
var role = currentUserService.Role == "1";
var feedback = new Feedback
{
Content = request.Content,
Expand All @@ -30,8 +24,8 @@ public async Task<Result> 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();
}
}
3 changes: 1 addition & 2 deletions MBS_COMMAND.Domain/Entities/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void CreateSlot(IEnumerable<Slot> slots)
{
var slot = slots.Select(x => new DomainEvent.Slot
{
SlotId = x.Id,
MentorId = x.MentorId,
StartTime = x.StartTime,
EndTime = x.EndTime,
Expand All @@ -43,7 +44,5 @@ public void CreateSlot(IEnumerable<Slot> slots)
IsBook = x.IsBook,
}).ToList();
RaiseDomainEvent(new DomainEvent.MentorSlotCreated(Guid.NewGuid(), slot));
Console.BackgroundColor = ConsoleColor.DarkGreen;
Console.WriteLine("MentorSlotCreatedDomainevent");
}
}
2 changes: 1 addition & 1 deletion MBS_COMMAND.Domain/MBS_COMMAND.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MBS_CONTRACT.SHARE" Version="1.1.12" />
<PackageReference Include="MBS_CONTRACT.SHARE" Version="1.1.14" />
</ItemGroup>

</Project>

0 comments on commit 8c6494f

Please sign in to comment.