v1.1.7
This commit is contained in:
@@ -0,0 +1,116 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Routing;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Sarand.Net.Standard.Dbas.Data;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
// Home - Ajax - Awaiting Activation controller
|
||||
//=======================================================================
|
||||
partial class HomeController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Items Awaiting Activation data.
|
||||
private class ActivationItemData
|
||||
{
|
||||
public String ItemType { get; set; }
|
||||
public String ItemTypeDesc { get; set; }
|
||||
public String ItemTypeDescPlural { get; set; }
|
||||
public long ItemCount { get; set; }
|
||||
public String ViewLink { get; set; }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Items Awaiting Activation ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_ItemsAwaitingActivation : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_ItemsAwaitingActivation(SaxModel_Admin model) : base(model) { }
|
||||
// Table list.
|
||||
public List<ActivationItemData> Items { get; } = new List<ActivationItemData>();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Home/Ajax/GetItemsAwaitingActivation")]
|
||||
public IActionResult Ajax_GetItemsAwaitingActivation(Model_Sport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetItemsAwaitingActivation";
|
||||
String messageTitle = Localiser["home.caption.application"];
|
||||
AjaxResponse_ItemsAwaitingActivation responseData = new AjaxResponse_ItemsAwaitingActivation(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Core Database connection.
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
|
||||
// Query to count items awaiting activation.
|
||||
Dictionary<String, int> tableRowCounts = new Dictionary<string, int>(StringComparer.OrdinalIgnoreCase);
|
||||
List<String> query = new List<string>()
|
||||
{
|
||||
// User accounts.
|
||||
"SELECT",
|
||||
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.UserAccount)) + "',",
|
||||
"ItemCount = Count(*)",
|
||||
"FROM UserAccount ua",
|
||||
"WHERE ua.Status = 'AWA'",
|
||||
// Organisations.
|
||||
"UNION SELECT",
|
||||
"ItemType = '" + DbQuery.FormatForCondition(nameof(Sax.DataItemType.Organisation)) + "',",
|
||||
"ItemCount = Count(*)",
|
||||
"FROM Organisation org",
|
||||
"WHERE org.Status = 'AWA'",
|
||||
};
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, query.Concat("\n")))
|
||||
{
|
||||
while (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
Sax.DataItemType itemType = EnumUtil.ParseEnum(dbResultSet.GetRecordValues().GetValue("ItemType").ToString(), Sax.DataItemType.Unknown);
|
||||
String itemTypeDesc = nameof(itemType);
|
||||
String itemTypeDescPlural = itemTypeDesc;
|
||||
String viewLink = "";
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
itemTypeDesc = "User Account";
|
||||
itemTypeDescPlural = "User Accounts";
|
||||
viewLink = Url.Action("", "User", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
case Sax.DataItemType.Organisation:
|
||||
itemTypeDesc = "Organisation";
|
||||
itemTypeDescPlural = "Organisations";
|
||||
viewLink = Url.Action("", "Organisation", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
}
|
||||
ActivationItemData activationItem = new ActivationItemData()
|
||||
{
|
||||
ItemType = nameof(itemType),
|
||||
ItemTypeDesc = itemTypeDesc,
|
||||
ItemTypeDescPlural = itemTypeDescPlural,
|
||||
ItemCount = dbResultSet.GetRecordValues().GetValue("ItemCount").AsLong(),
|
||||
ViewLink = viewLink,
|
||||
};
|
||||
responseData.Items.Add(activationItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -17,7 +17,7 @@ using System.Threading.Tasks;
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
public class HomeController : SaxController_Admin
|
||||
public partial class HomeController : SaxController_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
[HttpGet]
|
||||
public IActionResult Index()
|
||||
public IActionResult Index(String sta)
|
||||
{
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
@@ -37,6 +37,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
model.Paging.PageNo = 1;
|
||||
model.Paging.PageLength = 6;
|
||||
|
||||
// Default status.
|
||||
if (sta.StartsWithCI("Awa"))
|
||||
model.Filter.OrganisationStatusCategoryCode = nameof(SaxOrganisation.StatusCat.AwaitingOnly);
|
||||
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user