Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Activity detail
Browse files Browse the repository at this point in the history
  • Loading branch information
thientm27 committed Aug 22, 2023
1 parent 0d7c1e3 commit e4162c6
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ public IActionResult OnGetAsync(int? id)
{
return NotFound();
}
else
{
ClubActivity = clubActivity;
}

ClubActivity = clubActivity;

var participants = _clubActivityService.GetListStudentInActivity((int)id);
Student = participants ?? new List<Student>();
return Page();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
</td>
<td>
@* <a asp-page="./Edit" asp-route-id="@item.Id">Edit</a> | *@
<a asp-page="./ClubActivityInformationModel" asp-route-id="@item.Id">Details</a> |
<a asp-page="./ClubActivityInformation" asp-route-id="@item.Id">Details</a> |
</td>
</tr>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace ClubMemberShip.Service;

public interface IClubActivityService : IGenericService<ClubActivity>
{

public List<Student>? GetListStudentInActivity(int id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ namespace ClubMemberShip.Service;

public interface IParticipantService : IGenericService<Participant>
{

public List<Participant>? GetByCluActivityId(int clubActivityId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,24 @@ public override Result Delete(object idToDelete)

public override Result Add(ClubActivity newEntity)
{

var maxId = (Get() ?? new List<ClubActivity>()).Max(o => o.Id);
newEntity.Id = maxId + 1;
newEntity.Status = Status.Active;

UnitOfWork.ClubActivityRepo.Create(newEntity);
UnitOfWork.SaveChange();
return Result.Ok;
}

public List<Student>? GetListStudentInActivity(int id)
{
var listJoin = UnitOfWork.ParticipantRepo.Get(filter: o => o.ClubActivityId == id);

var listMemberShipId = listJoin.Select(o => o.MembershipId);
var listMemberShip = UnitOfWork.MemberShipRepo.Get(filter: o => listMemberShipId.Contains(o.Id));

var listStudentId = listMemberShip.Select(o => o.StudentId);

return UnitOfWork.StudentRepo.Get(filter: o => listStudentId.Contains(o.Id));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public override Result Add(Participant newEntity)
UnitOfWork.SaveChange();
return Result.Ok;
}

public List<Participant>? GetByCluActivityId(int clubActivityId)
{
return UnitOfWork.ParticipantRepo.Get(filter: o => o.ClubActivityId == clubActivityId);
}
}

0 comments on commit e4162c6

Please sign in to comment.