diff --git a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml deleted file mode 100644 index 0b49c8c..0000000 --- a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml +++ /dev/null @@ -1,49 +0,0 @@ -@page -@model ClubMemberShip.Web.Pages.PageUser.ClubBoardManage.DetailsModel - -@{ - ViewData["Title"] = "Details"; -} - -

Details

- -
-

ClubBoard

-
-
-
- @Html.DisplayNameFor(model => model.ClubBoard.Name) -
-
- @Html.DisplayFor(model => model.ClubBoard.Name) -
-
- @Html.DisplayNameFor(model => model.ClubBoard.ShortDecription) -
-
- @Html.DisplayFor(model => model.ClubBoard.ShortDecription) -
-
- @Html.DisplayNameFor(model => model.ClubBoard.LongDecription) -
-
- @Html.DisplayFor(model => model.ClubBoard.LongDecription) -
-
- @Html.DisplayNameFor(model => model.ClubBoard.Club) -
-
- @Html.DisplayFor(model => model.ClubBoard.Club.Code) -
-
- @Html.DisplayNameFor(model => model.ClubBoard.Status) -
-
- @Html.DisplayFor(model => model.ClubBoard.Status) -
-
-
-
- Edit | - Back to List -
diff --git a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml.cs b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml.cs deleted file mode 100644 index c49e306..0000000 --- a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.EntityFrameworkCore; -using ClubMemberShip.Repo.Models; - -namespace ClubMemberShip.Web.Pages.PageUser.ClubBoardManage -{ - public class DetailsModel : PageModel - { - private readonly ClubMemberShip.Repo.Models.ClubMembershipContext _context; - - public DetailsModel(ClubMemberShip.Repo.Models.ClubMembershipContext context) - { - _context = context; - } - - public ClubBoard ClubBoard { get; set; } = default!; - - public async Task OnGetAsync(int? id) - { - if (id == null || _context.ClubBoards == null) - { - return NotFound(); - } - - var clubboard = await _context.ClubBoards.FirstOrDefaultAsync(m => m.Id == id); - if (clubboard == null) - { - return NotFound(); - } - else - { - ClubBoard = clubboard; - } - return Page(); - } - } -} diff --git a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml index 1d51059..d84d3b8 100644 --- a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml +++ b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml @@ -1,4 +1,5 @@ @page +@using ClubMemberShip.Repo.Models @model ClubMemberShip.Web.Pages.PageUser.ClubBoardManage.EditModel @{ @@ -8,48 +9,104 @@

Edit

ClubBoard

-
+
- +
- + +
- + @{ + if (@Model.ClubBoard.Name == "Owner") + { + + } + else + { + + } + } +
- +
- +
- - - -
-
- +
+ + + + + + + + + + + + + @foreach (var item in Model.NotAddStudent) + { + + + + + + + + + } + +
+ @Html.DisplayNameFor(model => model.NotAddStudent[0].Code) + + @Html.DisplayNameFor(model => model.NotAddStudent[0].Name) + + @Html.DisplayNameFor(model => model.NotAddStudent[0].Address) + + @Html.DisplayNameFor(model => model.NotAddStudent[0].DateOfBirth) + + @Html.DisplayNameFor(model => model.NotAddStudent[0].Grade) + + @Html.DisplayNameFor(model => model.NotAddStudent[0].Major) +
+ @Html.DisplayFor(modelItem => item.Code) + + @Html.DisplayFor(modelItem => item.Name) + + @Html.DisplayFor(modelItem => item.Address) + + @Html.DisplayFor(modelItem => item.DateOfBirth) + + @Html.DisplayFor(modelItem => item.Grade.GradeYear.Year) + + @Html.DisplayFor(modelItem => item.Major.Name) +
+
- Back to List + Back to List
@section Scripts { - @{await Html.RenderPartialAsync("_ValidationScriptsPartial");} -} + @{ await Html.RenderPartialAsync("_ValidationScriptsPartial"); } +} \ No newline at end of file diff --git a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml.cs b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml.cs index 6d60140..921da15 100644 --- a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml.cs +++ b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml.cs @@ -1,77 +1,58 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; using Microsoft.AspNetCore.Mvc.Rendering; -using Microsoft.EntityFrameworkCore; using ClubMemberShip.Repo.Models; +using ClubMemberShip.Service; namespace ClubMemberShip.Web.Pages.PageUser.ClubBoardManage { public class EditModel : PageModel { - private readonly ClubMemberShip.Repo.Models.ClubMembershipContext _context; - - public EditModel(ClubMemberShip.Repo.Models.ClubMembershipContext context) + private IClubBoardService _clubBoardService; + private IClubServices _clubServices; + private IMemberRoleService _memberRoleService; + public IList NotAddStudent { get; set; } = default!; + [BindProperty(SupportsGet = true)] public int PageIndex1 { get; set; } = 1; + public int PageSize1 { get; set; } = 3; + public int TotalPages1; + + public EditModel(IClubBoardService clubBoardService, IClubServices clubServices, + IMemberRoleService memberRoleService) { - _context = context; + _clubBoardService = clubBoardService; + _clubServices = clubServices; + _memberRoleService = memberRoleService; } - [BindProperty] - public ClubBoard ClubBoard { get; set; } = default!; + [BindProperty] public ClubBoard ClubBoard { get; set; } = default!; - public async Task OnGetAsync(int? id) + public IActionResult OnGet(int? id) { - if (id == null || _context.ClubBoards == null) + if (id == null) { return NotFound(); } - var clubboard = await _context.ClubBoards.FirstOrDefaultAsync(m => m.Id == id); + var clubboard = _clubBoardService.GetById(id); if (clubboard == null) { return NotFound(); } - ClubBoard = clubboard; - ViewData["ClubId"] = new SelectList(_context.Clubs, "Id", "Code"); - return Page(); - } - - // To protect from overposting attacks, enable the specific properties you want to bind to. - // For more details, see https://aka.ms/RazorPagesCRUD. - public async Task OnPostAsync() - { - if (!ModelState.IsValid) - { - return Page(); - } - _context.Attach(ClubBoard).State = EntityState.Modified; + ClubBoard = clubboard; + ViewData["ClubId"] = new SelectList(_clubServices.Get(), "Id", "Name"); - try - { - await _context.SaveChangesAsync(); - } - catch (DbUpdateConcurrencyException) - { - if (!ClubBoardExists(ClubBoard.Id)) - { - return NotFound(); - } - else - { - throw; - } - } - return RedirectToPage("./Index"); + var data = _memberRoleService.GetPaginationAllMemberOfBoard(PageIndex1 - 1, PageSize1, ClubBoard.Id); + TotalPages1 = data.TotalPagesCount; + NotAddStudent = data.Items.ToList(); + return Page(); } - private bool ClubBoardExists(int id) + public IActionResult OnPost() { - return (_context.ClubBoards?.Any(e => e.Id == id)).GetValueOrDefault(); + _clubBoardService.Update(ClubBoard); + return RedirectToPage("./Index", new { clubId = ClubBoard.ClubId }); } } -} +} \ No newline at end of file diff --git a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Index.cshtml b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Index.cshtml index 63e978b..15a4fe4 100644 --- a/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Index.cshtml +++ b/Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Index.cshtml @@ -52,7 +52,6 @@ Edit | - Details | @{ if (item.Name != "Owner") diff --git a/Clup-MemberShip/ClubMemberShip.Service/IMemberRoleService.cs b/Clup-MemberShip/ClubMemberShip.Service/IMemberRoleService.cs index b64efb3..72a22f1 100644 --- a/Clup-MemberShip/ClubMemberShip.Service/IMemberRoleService.cs +++ b/Clup-MemberShip/ClubMemberShip.Service/IMemberRoleService.cs @@ -1,4 +1,5 @@ using ClubMemberShip.Repo.Models; +using ClubMemberShip.Repo.Utils; namespace ClubMemberShip.Service; @@ -6,4 +7,5 @@ public interface IMemberRoleService : IGenericService { public void AddMultipleMember(int clubId, int clubBoardId, List studentId); public List GetAllMemberOfBoard(int boardId); + public Pagination GetPaginationAllMemberOfBoard(int pageIndex, int pageSize, int boardId); } \ No newline at end of file diff --git a/Clup-MemberShip/ClubMemberShip.Service/Service/MemberRoleService.cs b/Clup-MemberShip/ClubMemberShip.Service/Service/MemberRoleService.cs index 8c809fb..9d25b16 100644 --- a/Clup-MemberShip/ClubMemberShip.Service/Service/MemberRoleService.cs +++ b/Clup-MemberShip/ClubMemberShip.Service/Service/MemberRoleService.cs @@ -78,7 +78,13 @@ public List GetAllMemberOfBoard(int clubId) var membership = UnitOfWork.MemberShipRepo.Get(filter: o => listId.Contains(o.Id)); - var listStudentId = membership.Select(o => o.Id); - return UnitOfWork.StudentRepo.Get(filter: o => listStudentId.Contains(o.Id)); + var listStudentId = membership.Select(o => o.StudentId); + return UnitOfWork.StudentRepo.Get(filter: o => listStudentId.Contains(o.Id), includeProperties: "Grade,Major"); + } + + public Pagination GetPaginationAllMemberOfBoard(int pageIndex, int pageSize, int boardId) + { + var listEntities = GetAllMemberOfBoard(boardId); + return UnitOfWork.StudentRepo.ToPagination(listEntities, pageIndex, pageSize); } } \ No newline at end of file