many bug fixes and features added
This commit is contained in:
@@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using SportsDivision.Application.DTOs;
|
||||
using SportsDivision.Application.Interfaces;
|
||||
using SportsDivision.Domain.Enums;
|
||||
using SportsDivision.Web.Helpers;
|
||||
|
||||
namespace SportsDivision.Web.Controllers;
|
||||
|
||||
@@ -18,7 +19,7 @@ public class TournamentController : Controller
|
||||
_eventService = eventService;
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Index(TournamentStatus? status, bool showArchived = false)
|
||||
public async Task<IActionResult> Index(TournamentStatus? status, bool showArchived = false, int page = 1, int pageSize = PaginationHelper.PageSize)
|
||||
{
|
||||
var tournaments = await _tournamentService.GetAllAsync(includeArchived: showArchived);
|
||||
|
||||
@@ -30,7 +31,7 @@ public class TournamentController : Controller
|
||||
ViewBag.SelectedStatus = status;
|
||||
ViewBag.ShowArchived = showArchived;
|
||||
|
||||
return View(tournaments);
|
||||
return View(this.Page(tournaments, page, pageSize));
|
||||
}
|
||||
|
||||
public async Task<IActionResult> Details(int id)
|
||||
@@ -45,6 +46,8 @@ public class TournamentController : Controller
|
||||
|
||||
var eventLevels = await _tournamentService.GetEventLevelsAsync(id);
|
||||
ViewBag.EventLevels = eventLevels;
|
||||
ViewBag.Events = await _eventService.GetAllAsync();
|
||||
ViewBag.Levels = await _tournamentService.GetAllEventLevelsAsync();
|
||||
|
||||
return View(tournament);
|
||||
}
|
||||
@@ -158,32 +161,6 @@ public class TournamentController : Controller
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> SetupEventLevels(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var tournament = await _tournamentService.GetByIdAsync(id);
|
||||
if (tournament == null)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
var eventLevels = await _tournamentService.GetEventLevelsAsync(id);
|
||||
var events = await _eventService.GetAllAsync();
|
||||
|
||||
ViewBag.Tournament = tournament;
|
||||
ViewBag.Events = events;
|
||||
ViewBag.EventLevels = eventLevels;
|
||||
|
||||
return View(eventLevels);
|
||||
}
|
||||
catch (KeyNotFoundException)
|
||||
{
|
||||
return NotFound();
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> AddEventLevel(TournamentEventLevelCreateDto dto)
|
||||
@@ -202,12 +179,12 @@ public class TournamentController : Controller
|
||||
TempData["ErrorMessage"] = ex.Message;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(SetupEventLevels), new { id = dto.TournamentId });
|
||||
return RedirectToAction(nameof(Details), new { id = dto.TournamentId });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> RemoveEventLevel(int tournamentEventLevelId, int tournamentId)
|
||||
public async Task<IActionResult> RemoveEventLevel(int tournamentEventLevelId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -223,7 +200,7 @@ public class TournamentController : Controller
|
||||
TempData["ErrorMessage"] = ex.Message;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(SetupEventLevels), new { id = tournamentId });
|
||||
return RedirectToAction(nameof(Details), new { id });
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
@@ -291,7 +268,7 @@ public class TournamentController : Controller
|
||||
|
||||
[HttpPost]
|
||||
[ValidateAntiForgeryToken]
|
||||
public async Task<IActionResult> ToggleAgeWaiver(int tournamentEventLevelId, int tournamentId)
|
||||
public async Task<IActionResult> ToggleAgeWaiver(int tournamentEventLevelId, int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -307,6 +284,6 @@ public class TournamentController : Controller
|
||||
TempData["ErrorMessage"] = ex.Message;
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(SetupEventLevels), new { id = tournamentId });
|
||||
return RedirectToAction(nameof(Details), new { id });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user