95 lines
3.5 KiB
C#
95 lines
3.5 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Logging;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Bus;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Dbas;
|
|
using Saxonite.Net.Core.Web.Base.App;
|
|
using Saxonite.Net.Core.Web.Online.Models;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
using Saxonite.Net.Standard.Base.Bus;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Saxonite.Net.Core.Web.Online.Controllers
|
|
{
|
|
//=======================================================================
|
|
// Online Reference Controller - Ajax actions only.
|
|
//=======================================================================
|
|
public partial class ReferenceController : SaxController_Online
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
public ReferenceController(SaxLocaliser localiser, ILogger<HomeController> logger) :
|
|
base(localiser, logger)
|
|
{}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Sports
|
|
//-------------------------------------------------------------------
|
|
private class AjaxResponse_SportList : AjaxResponse_Base
|
|
{
|
|
public List<SaxModel_Online.SportData> Sports { get; } = new List<SaxModel_Online.SportData>();
|
|
}
|
|
//-------------------------------------------------------------------
|
|
[HttpPost]
|
|
[Route("Reference/Ajax/GetSports")]
|
|
public IActionResult Ajax_GetSportList(Model_Reference model)
|
|
{
|
|
String fn = GetType().Name + ".Ajax_GetSportList";
|
|
String messageTitle = Localiser["reference.caption.sports"];
|
|
AjaxResponse_SportList responseData = new AjaxResponse_SportList();
|
|
|
|
// Validate session and referrer.
|
|
if (!ValidReferer) return Forbid();
|
|
// User doesn't have to be logged in, eg. to register organisation.
|
|
//if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
|
|
|
// Populate sports.
|
|
foreach (SaxModel_Online.SportData sportData in model.GetSportDataList_Active())
|
|
responseData.Sports.Add(sportData);
|
|
|
|
// Complete response.
|
|
responseData.Success = true;
|
|
|
|
return Json(responseData);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Regions
|
|
//-------------------------------------------------------------------
|
|
private class AjaxResponse_RegionList : AjaxResponse_Base
|
|
{
|
|
public List<SaxModel_Online.RegionData> Regions { get; } = new List<SaxModel_Online.RegionData>();
|
|
}
|
|
//-------------------------------------------------------------------
|
|
[HttpPost]
|
|
[Route("Reference/Ajax/GetRegions")]
|
|
public IActionResult Ajax_GetRegionList(Model_Reference model)
|
|
{
|
|
String fn = GetType().Name + ".Ajax_GetRegionList";
|
|
String messageTitle = Localiser["reference.caption.regions"];
|
|
AjaxResponse_RegionList responseData = new AjaxResponse_RegionList();
|
|
|
|
// Validate session and referrer.
|
|
if (!ValidReferer) return Forbid();
|
|
// User doesn't have to be logged in to query regions, eg. for organisation request.
|
|
//if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
|
|
|
|
// Populate regions.
|
|
foreach (SaxModel_Online.RegionData regionData in model.GetRegionDataList_Active())
|
|
responseData.Regions.Add(regionData);
|
|
|
|
// Complete response.
|
|
responseData.Success = true;
|
|
|
|
return Json(responseData);
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|