This repository has been archived by the owner on Mar 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit basic information club board, remove detail page club board
- Loading branch information
Showing
7 changed files
with
111 additions
and
157 deletions.
There are no files selected for viewing
49 changes: 0 additions & 49 deletions
49
Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Details.cshtml.cs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 29 additions & 48 deletions
77
Clup-MemberShip/ClubMemberShip.Present/Pages/PageUser/ClubBoardManage/Edit.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<Student> 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<IActionResult> 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<IActionResult> 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 }); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
using ClubMemberShip.Repo.Models; | ||
using ClubMemberShip.Repo.Utils; | ||
|
||
namespace ClubMemberShip.Service; | ||
|
||
public interface IMemberRoleService : IGenericService<MemberRole> | ||
{ | ||
public void AddMultipleMember(int clubId, int clubBoardId, List<int> studentId); | ||
public List<Student> GetAllMemberOfBoard(int boardId); | ||
public Pagination<Student> GetPaginationAllMemberOfBoard(int pageIndex, int pageSize, int boardId); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters