Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
PhucNghi176 committed Nov 11, 2024
1 parent b729df6 commit fba1dab
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,37 @@ public async Task<Result> Handle(Command.AddMentorToGroup request, CancellationT
return Result.Failure(new Error("400", "Group already has a mentor"));
}

group.MentorId = request.MentorId;
/*group.MentorId = request.MentorId;
groupRepository.Update(group);
await unitOfWork.SaveChangesAsync(cancellationToken);
await mailService.SendMail(new MailContent
{
To = user.Email,
Subject = $"You have been added to group {group.Name} as a mentor",
});*/
await mailService.SendMail(new MailContent
{
To = user.Email,
Subject = $"You have been invited to group {group.Name} as a mentor",
Body = $@"
<p>Dear {user.FullName},</p>
<p>You have been invited to join the group <strong>{group.Name}</strong> as a mentor.</p>
<p>Please choose an option below:</p>
<div>
<a href=""https://your-api-url.com/api/invite/response?mentorId={user.Id}&groupId={group.Id}&isAccepted=true""
style=""padding:10px 20px; color:#fff; background-color:green; text-decoration:none; border-radius:5px;"">
Accept
</a>
<a href=""https://your-api-url.com/api/invite/response?mentorId={user.Id}&groupId={group.Id}&isAccepted=false""
style=""padding:10px 20px; color:#fff; background-color:red; text-decoration:none; border-radius:5px; margin-left:10px;"">
Decline
</a>
</div>
<p>Thank you!</p>
",

});

return Result.Success();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,14 @@ public async Task<Result> Handle(Command.CreateScheduleCommand request, Cancella
{
return Result.Failure(new Error("500", "Not enough points to book"));
}

var s= await subjectRepository.FindByIdAsync(request.SubjectId, cancellationToken);
var schedule = new Schedule
{
Id = Guid.NewGuid(),
StartTime = start,
EndTime = end,
Date = slot.Date,
MentorId = slot.MentorId ?? new Guid(),
SubjectId = request.SubjectId,
GroupId = group.Id,
SlotId = slot.Id,
IsAccepted = isAccepted,
Expand Down
4 changes: 3 additions & 1 deletion MBS_COMMAND.Contract/Services/Mentors/Command.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

namespace MBS_COMMAND.Contract.Services.Mentors;

public class Command
public static class Command
{
public record CreateMentorCommand(Guid MentorId) : ICommand;

public record MentorAcceptOrDeclineFromGroupCommand(Guid MentorId, bool IsAccepted,Guid GroupId) : ICommand;
}
4 changes: 1 addition & 3 deletions MBS_COMMAND.Domain/Entities/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@ public class Schedule : Entity<Guid>, IAuditableEntity
public TimeOnly StartTime { get; set; }
public TimeOnly EndTime { get; set; }
public DateOnly Date { get; set; }
public Guid SubjectId { get; set; }
public int IsAccepted { get; set; } // 0: Pending, 1: Accepted, 2: Rejected

public virtual Subject? Subject { get; set; }

public DateTimeOffset CreatedOnUtc { get; set; }
public DateTimeOffset? ModifiedOnUtc { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -299,9 +299,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)
b.Property<TimeOnly>("StartTime")
.HasColumnType("time");

b.Property<Guid>("SubjectId")
.HasColumnType("uniqueidentifier");

b.HasKey("Id");

b.HasIndex("GroupId");
Expand All @@ -310,8 +307,6 @@ protected override void BuildModel(ModelBuilder modelBuilder)

b.HasIndex("SlotId");

b.HasIndex("SubjectId");

b.ToTable("Schedules");
});

Expand Down Expand Up @@ -679,19 +674,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.HasOne("MBS_COMMAND.Domain.Entities.Subject", "Subject")
.WithMany()
.HasForeignKey("SubjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();

b.Navigation("Group");

b.Navigation("Mentor");

b.Navigation("Slot");

b.Navigation("Subject");
});

modelBuilder.Entity("MBS_COMMAND.Domain.Entities.Skill", b =>
Expand Down

0 comments on commit fba1dab

Please sign in to comment.