Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
PhucNghi176 committed Oct 18, 2024
1 parent addc291 commit 8e06b69
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion MBS-COMMAND.API/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@
]
},
"AllowedHosts": "*",
"Domain" : "http://103.162.14.116:4000/"
"Domain" : "http://103.162.14.116:4000"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MBS_COMMAND.Contract.Abstractions.Messages;
using MBS_COMMAND.Contract.Abstractions.Shared;
using MBS_COMMAND.Contract.Services.Feedbacks;
using MBS_COMMAND.Domain.Abstractions;
using MBS_COMMAND.Domain.Abstractions.Repositories;
using MBS_COMMAND.Domain.Entities;

Expand All @@ -10,12 +11,12 @@ public class CreateFeedbackCommandHandler : ICommandHandler<Command.CreateFeedba
{
private readonly IRepositoryBase<Feedback, Guid> _feedbackRepository;
private readonly ICurrentUserService _currentUserService;

public CreateFeedbackCommandHandler(IRepositoryBase<Feedback, Guid> feedbackRepository,
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)
Expand All @@ -30,6 +31,7 @@ public async Task<Result> Handle(Command.CreateFeedback request, CancellationTok
IsMentor = role,
};
_feedbackRepository.Add(feedback);
await _unitOfWork.SaveChangesAsync(cancellationToken);
return Result.Success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ public async Task<Result> Handle(Command.AddMemberToGroup request, CancellationT
var u = await userRepository.FindByIdAsync(request.MemberId, cancellationToken);
if (u == null)
return Result.Failure(new Error("404", "User Not Found"));
if(u.Role==1)
return Result.Failure(new Error("422", "Mentor cannot be added to group"));
var g = await groupRepository.FindSingleAsync(x => x.Id == request.GroupId, cancellationToken);
if (g == null)
return Result.Failure(new Error("404", "Group Not Found"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public async Task<Result> Handle(Command.CreateScheduleCommand request, Cancella
MentorId = slot.MentorId ?? new Guid(),
SubjectId = request.SubjectId,
GroupId = group.Id,
IsBooked = true,
};

slot.IsBook = true;
Expand Down
2 changes: 0 additions & 2 deletions MBS_COMMAND.Domain/Entities/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ public class Schedule : Entity<Guid>, IAuditableEntity
public virtual Slot? Slot { get; set; }
public Guid GroupId { get; set; }
public virtual Group? Group { get; set; }

public TimeOnly StartTime { get; set; }
public TimeOnly EndTime { get; set; }
public DateOnly Date { get; set; }
public Guid SubjectId { get; set; }
public bool IsBooked { get; set; }=false;
public virtual Subject? Subject { get; set; }
public DateTimeOffset CreatedOnUtc { get ; set ; }
public DateTimeOffset? ModifiedOnUtc { get ; set ; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<Guid>("GroupId")
.HasColumnType("uniqueidentifier");

b.Property<bool>("IsBooked")
.HasColumnType("bit");

b.Property<bool>("IsDeleted")
.HasColumnType("bit");

Expand Down

0 comments on commit 8e06b69

Please sign in to comment.