v1.2.3.2
This commit is contained in:
@@ -0,0 +1,184 @@
|
||||
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 Controller - Ajax - Application Stats
|
||||
//=======================================================================
|
||||
partial class HomeController
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Application Stats data.
|
||||
private class ApplicationStatsData
|
||||
{
|
||||
public class UserStatsData
|
||||
{
|
||||
public String Caption { get; set; }
|
||||
public AjaxResponse_Data.ItemLabelValue Awaiting { get; set; }
|
||||
public String AwaitingLink { get; set; }
|
||||
public List<AjaxResponse_Data.ItemLabelValue> OnlineStats { get; set; }
|
||||
public String OnlineLink { get; set; }
|
||||
}
|
||||
public UserStatsData User { get; } = new UserStatsData();
|
||||
public class OrganisationStatsData
|
||||
{
|
||||
public String Caption { get; set; }
|
||||
public AjaxResponse_Data.ItemLabelValue Awaiting { get; set; }
|
||||
public String AwaitingLink { get; set; }
|
||||
}
|
||||
public OrganisationStatsData Organisation { get; } = new OrganisationStatsData();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Get Application Stats ajax request.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_ApplicationStats : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_ApplicationStats(SaxModel_Admin model) : base(model) { }
|
||||
// Table list.
|
||||
public ApplicationStatsData Stats { get; } = new ApplicationStatsData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("Home/Ajax/GetApplicationStats")]
|
||||
public IActionResult Ajax_GetApplicationStats(Model_Sport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetApplicationStats";
|
||||
String messageTitle = Localiser["home.caption.application"];
|
||||
AjaxResponse_ApplicationStats responseData = new AjaxResponse_ApplicationStats(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Captions.
|
||||
responseData.Stats.User.Caption = Localiser["user.caption.users"];
|
||||
responseData.Stats.Organisation.Caption = Localiser["organisation.caption.organisations"];
|
||||
|
||||
// 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())
|
||||
{
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
Sax.DataItemType itemType = EnumUtil.ParseEnum(values.GetValue("ItemType").ToString(), Sax.DataItemType.Unknown);
|
||||
int itemCount = (int)values.GetValue("ItemCount").AsLong();
|
||||
switch (itemType)
|
||||
{
|
||||
case Sax.DataItemType.UserAccount:
|
||||
responseData.Stats.User.Awaiting = new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.awaiting.activation"], Value = itemCount.ToString() };
|
||||
responseData.Stats.User.AwaitingLink = Url.Action("", "User", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
case Sax.DataItemType.Organisation:
|
||||
responseData.Stats.Organisation.Awaiting = new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.awaiting.activation"], Value = itemCount.ToString() };
|
||||
responseData.Stats.Organisation.AwaitingLink = Url.Action("", "Organisation", new RouteValueDictionary() { { "sta", "Await" } }).TrimStart('/');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Query to count users online.
|
||||
DateTime today = DateTime.Today;
|
||||
DateTime now = DateTime.Now;
|
||||
const String online5Mins = "Online5Mins";
|
||||
const String online15Mins = "Online15Mins";
|
||||
const String online30Mins = "Online30Mins";
|
||||
const String online60Mins = "Online60Mins";
|
||||
const String onlineToday = "OnlineToday";
|
||||
const String onlineWeek = "OnlineWeek";
|
||||
const String onlineMonth = "OnlineMonth";
|
||||
query = new List<string>()
|
||||
{
|
||||
// Users Online last 5 mins.
|
||||
"Select '" + online5Mins + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateTimeForCondition(now.AddMinutes(-5)) + ") ItemCount ",
|
||||
"Union Select '" + online15Mins + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateTimeForCondition(now.AddMinutes(-15)) + ") ItemCount ",
|
||||
"Union Select '" + online30Mins + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateTimeForCondition(now.AddMinutes(-30)) + ") ItemCount ",
|
||||
"Union Select '" + online60Mins + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateTimeForCondition(now.AddMinutes(-60)) + ") ItemCount ",
|
||||
"Union Select '" + onlineToday + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateForCondition(today) + ") ItemCount ",
|
||||
"Union Select '" + onlineWeek + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateForCondition(DateUtil.StartOfWorkingWeek(today)) + ") ItemCount ",
|
||||
"Union Select '" + onlineMonth + "' ItemType, (Select Count(*) From UserOnline Where OnlineAt>=" + DbQuery.FormatDateForCondition(DateUtil.StartOfMonth(today)) + ") ItemCount ",
|
||||
};
|
||||
using (DbResultSet dbResultSet = DbResultSet_DataReader.ExecuteQuery(db, query.Concat("\n")))
|
||||
{
|
||||
while (dbResultSet != null && dbResultSet.NextRecord())
|
||||
{
|
||||
if (responseData.Stats.User.OnlineStats == null)
|
||||
responseData.Stats.User.OnlineStats = new List<AjaxResponse_Data.ItemLabelValue>();
|
||||
NamedValue.Map values = dbResultSet.GetRecordValues();
|
||||
String itemType = values.GetValue("ItemType").ToString();
|
||||
int itemCount = (int)values.GetValue("ItemCount").AsLong();
|
||||
switch (itemType)
|
||||
{
|
||||
case online5Mins:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.last5Mins"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case online15Mins:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.last15Mins"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case online30Mins:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.last30Mins"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case online60Mins:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.last60Mins"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case onlineToday:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.today"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case onlineWeek:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.thisWeek"], Value = itemCount.ToString() });
|
||||
break;
|
||||
case onlineMonth:
|
||||
if (itemCount > 0)
|
||||
responseData.Stats.User.OnlineStats.Add(new AjaxResponse_Data.ItemLabelValue() { Label = Localiser["label.online.thisMonth"], Value = itemCount.ToString() });
|
||||
break;
|
||||
}
|
||||
responseData.Stats.User.OnlineLink = Url.Action("", "UsersOnline", new RouteValueDictionary() { }).TrimStart('/');
|
||||
}
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
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);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -45,28 +45,34 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
if (StringUtil.IsEmpty(AppConfig.URL.Online.Root))
|
||||
return Json(responseData.SetMessage(messageTitle, "Root online URL not specified."));
|
||||
|
||||
// Identify item.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
if (!SysId.IsValid(organisationId))
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
SaLogger.Warn(fn + " Request to get activation info without valid organisation Id.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
}
|
||||
|
||||
// Retrieve item.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve organisation for Id: '" + model.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
if (StringUtil.IsEmpty(AppConfig.URL.Online.Root))
|
||||
return Json(responseData.SetMessage(messageTitle, "Root online URL not specified."));
|
||||
|
||||
// Construct response.
|
||||
PopulateOrganisationResponseData(organisation, responseData.organisation);
|
||||
GetOrganisationMembers(model, organisationId, responseData.Members);
|
||||
// Identify item.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
if (!SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Request to get activation info without valid organisation Id.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
}
|
||||
|
||||
// Retrieve item.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve organisation for Id: '" + model.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateOrganisationResponseData(organisation, responseData.organisation);
|
||||
GetOrganisationMembers(model, organisationId, responseData.Members);
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
@@ -105,10 +111,14 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Retrieve existing item.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
using (SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId))
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsDisposable> disposableItems = new DisposableCollection<SacsDisposable>())
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SysId organisationId = model.OrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null && SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve organisation for. : '" + model.OrganisationId + "'");
|
||||
@@ -116,93 +126,87 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
}
|
||||
|
||||
// Retrieve users.
|
||||
using (DisposableCollection<OrganisationMemberData> organisationMembersToActivate = new DisposableCollection<OrganisationMemberData>())
|
||||
List<OrganisationMemberData> organisationMembersToActivate = new List<OrganisationMemberData>();
|
||||
foreach (String userOrganisationId in model.OrganisationMemberIds)
|
||||
{
|
||||
foreach (String userOrganisationId in model.OrganisationMemberIds)
|
||||
if (userOrganisationId == null) continue;
|
||||
OrganisationMemberData organisationMember = new OrganisationMemberData();
|
||||
disposableItems.Add(organisationMember);
|
||||
organisationMember.UserOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId.ToSysId());
|
||||
organisationMember.UserAccount = AccountMgr.GetUserAccountById(organisationMember.UserOrganisation?.UserAccountId ?? null);
|
||||
if (organisationMember.UserOrganisation == null)
|
||||
{
|
||||
if (userOrganisationId == null) continue;
|
||||
OrganisationMemberData organisationMember = new OrganisationMemberData();
|
||||
organisationMember.UserOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId.ToSysId());
|
||||
organisationMember.UserAccount = AccountMgr.GetUserAccountById(organisationMember.UserOrganisation?.UserAccountId ?? null);
|
||||
if (organisationMember.UserOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user organisation. Id: '" + userOrganisationId + "'");
|
||||
organisationMember.Dispose();
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (organisationMember.UserAccount == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user account . Id: '" + organisationMember.UserOrganisation.UserAccountId + "'");
|
||||
organisationMember.Dispose();
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (organisationMember.UserAccount.Status != SaStatus.Awaiting)
|
||||
{
|
||||
SaLogger.Warn(fn + " User organisation is not awaiting. Id: '" + userOrganisationId + "'. Status: " + organisationMember.UserAccount.StatusDesc);
|
||||
organisationMember.Dispose();
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// Check if this user is to be activated.
|
||||
bool activateUser = false;
|
||||
String controlName_Activate = "MemberActivate_" + userOrganisationId;
|
||||
foreach (String key in Request.Form.Keys)
|
||||
{
|
||||
if (key.EqualsCI(controlName_Activate))
|
||||
{
|
||||
activateUser = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (activateUser)
|
||||
organisationMembersToActivate.Add(organisationMember);
|
||||
else organisationMember.Dispose();
|
||||
organisationMember = null;
|
||||
SaLogger.Warn(fn + " Failed to retrieve user organisation. Id: '" + userOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
|
||||
if (organisationMembersToActivate.IsEmpty())
|
||||
if (organisationMember.UserAccount == null)
|
||||
{
|
||||
// No users to be activated.
|
||||
// Check that organisation already has active members.
|
||||
if (AccountMgr.GetOrganisationMemberCount(organisation.Id) < 1)
|
||||
SaLogger.Warn(fn + " Failed to retrieve user account . Id: '" + organisationMember.UserOrganisation.UserAccountId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (organisationMember.UserAccount.Status != SaStatus.Awaiting)
|
||||
{
|
||||
SaLogger.Warn(fn + " User organisation is not awaiting. Id: '" + userOrganisationId + "'. Status: " + organisationMember.UserAccount.StatusDesc);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
// Check if this user is to be activated.
|
||||
bool activateUser = false;
|
||||
String controlName_Activate = "MemberActivate_" + userOrganisationId;
|
||||
foreach (String key in Request.Form.Keys)
|
||||
{
|
||||
if (key.EqualsCI(controlName_Activate))
|
||||
{
|
||||
SaLogger.Warn(fn + " Unable to activate Organisation - no active members. Id: '" + SysId.ToString(organisationId));
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["organisation.activate.msg.no.active.members"]));
|
||||
activateUser = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (activateUser)
|
||||
organisationMembersToActivate.Add(organisationMember);
|
||||
}
|
||||
|
||||
// Activate organisation.
|
||||
organisation.Status = Sarand.Net.Standard.Base.Core.SaStatus.Active;
|
||||
if (!AccountMgr.UpdateOrganisation(organisation, DbUpdateInfo))
|
||||
if (organisationMembersToActivate.IsEmpty())
|
||||
{
|
||||
// No users to be activated.
|
||||
// Check that organisation already has active members.
|
||||
if (AccountMgr.GetOrganisationMemberCount(organisation.Id) < 1)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update organisation [Id:" + SysId.ToString(organisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
SaLogger.Warn(fn + " Unable to activate Organisation - no active members. Id: '" + SysId.ToString(organisationId));
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["organisation.activate.msg.no.active.members"]));
|
||||
}
|
||||
}
|
||||
|
||||
// Activate awaiting members and send welcome email to each.
|
||||
foreach (OrganisationMemberData organisationMember in organisationMembersToActivate)
|
||||
// Activate organisation.
|
||||
organisation.Status = Sarand.Net.Standard.Base.Core.SaStatus.Active;
|
||||
if (!AccountMgr.UpdateOrganisation(organisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update organisation [Id:" + SysId.ToString(organisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
|
||||
// Activate awaiting members and send welcome email to each.
|
||||
foreach (OrganisationMemberData organisationMember in organisationMembersToActivate)
|
||||
{
|
||||
if (organisationMember.UserOrganisation == null) continue;
|
||||
if (AccountMgr.UpdateUserOrganisation(organisationMember.UserOrganisation, DbUpdateInfo))
|
||||
{
|
||||
if (organisationMember.UserOrganisation == null) continue;
|
||||
if (AccountMgr.UpdateUserOrganisation(organisationMember.UserOrganisation, DbUpdateInfo))
|
||||
if (organisationMember.UserAccount == null) continue;
|
||||
organisationMember.UserAccount.Status = SaStatus.Active;
|
||||
if (AccountMgr.UpdateUserAccount(organisationMember.UserAccount, DbUpdateInfo))
|
||||
{
|
||||
if (organisationMember.UserAccount == null) continue;
|
||||
organisationMember.UserAccount.Status = SaStatus.Active;
|
||||
if (AccountMgr.UpdateUserAccount(organisationMember.UserAccount, DbUpdateInfo))
|
||||
{
|
||||
// Send activation email.
|
||||
if (SendAccountActivatedEmail(this, organisationMember.UserAccount))
|
||||
SaLogger.Info(fn + " User Activation email sent to " + organisationMember.UserAccount.EmailAddress, true);
|
||||
else SaLogger.Warn(fn + " Failed to send User Activation email to " + organisationMember.UserAccount.EmailAddress);
|
||||
}
|
||||
else
|
||||
SaLogger.Warn(fn + " Failed to update user account [Id:" + SysId.ToString(organisationMember.UserAccount.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
// Send activation email.
|
||||
if (SendAccountActivatedEmail(this, organisationMember.UserAccount))
|
||||
SaLogger.Info(fn + " User Activation email sent to " + organisationMember.UserAccount.EmailAddress, true);
|
||||
else SaLogger.Warn(fn + " Failed to send User Activation email to " + organisationMember.UserAccount.EmailAddress);
|
||||
}
|
||||
else
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(organisationMember.UserOrganisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
SaLogger.Warn(fn + " Failed to update user account [Id:" + SysId.ToString(organisationMember.UserAccount.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateOrganisationResponseData(organisation, responseData.organisation);
|
||||
else
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(organisationMember.UserOrganisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateOrganisationResponseData(organisation, responseData.organisation);
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
@@ -216,7 +220,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
/// <para>NB URL must be to the Online application.</para>
|
||||
/// <para>NB Encryption must be done with the Online logic.</para>
|
||||
/// </summary>
|
||||
public static bool SendAccountActivatedEmail (SaxController_Admin controller, SaxUserAccount userAccount)
|
||||
public static bool SendAccountActivatedEmail(SaxController_Admin controller, SaxUserAccount userAccount)
|
||||
{
|
||||
SaEmailData emailData = new SaEmailData();
|
||||
emailData.Config = controller.EmailConfig;
|
||||
|
||||
@@ -119,6 +119,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = true;
|
||||
prmUserOrganisation.UserAccountStatusCat = SaxUserAccount.StatusCat.AwaitingOnly;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.NotDeleted;
|
||||
model.Paging.ItemTotal = (ulong)AccountMgr.GetUserOrganisationCount(prmUserOrganisation);
|
||||
model.PopulatePagingTo(prmUserOrganisation.ResultsPaging);
|
||||
@@ -193,37 +194,46 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Identify item.
|
||||
SysId userOrganisationId = model.UserOrganisationId.ToSysId();
|
||||
if (!SysId.IsValid(userOrganisationId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
// Retrieve item.
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId);
|
||||
if (userOrganisation == null)
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve User Organisation for Id: '" + model.UserOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
|
||||
// Identify item.
|
||||
SysId userOrganisationId = model.UserOrganisationId.ToSysId();
|
||||
if (!SysId.IsValid(userOrganisationId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
// Retrieve item.
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId);
|
||||
disposableItems.Add(userOrganisation);
|
||||
if (userOrganisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve User Organisation for Id: '" + model.UserOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Retrieve User Account.
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user account for Id: '" + userOrganisation.UserAccountId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Retrieve Organisation.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId);
|
||||
disposableItems.Add(organisation);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve organisation for Id: '" + userOrganisation.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
// Retrieve User Account.
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userOrganisation.UserAccountId);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user account for Id: '" + userOrganisation.UserAccountId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Retrieve Organisation.
|
||||
SaxOrganisation organisation = AccountMgr.GetOrganisationById(userOrganisation.OrganisationId);
|
||||
if (organisation == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve organisation for Id: '" + userOrganisation.OrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
@@ -248,94 +258,109 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// User account.
|
||||
SysId userAccountId = model.MemberUserAccountId.ToSysId();
|
||||
SaxUserAccount userAccount = null;
|
||||
if (!SysId.IsValid(userAccountId) && !StringUtil.IsEmpty(model.MemberUserEmailAddress))
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
userAccount = AccountMgr.GetUserAccountByEmailAddress(model.MemberUserEmailAddress);
|
||||
userAccountId = userAccount?.Id ?? new SysId();
|
||||
}
|
||||
if (!SysId.IsValid(userAccountId))
|
||||
{
|
||||
SaLogger.Warn(fn + " User Account must be identified");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// Organisation.
|
||||
SysId organisationId = model.MemberOrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = null;
|
||||
if (!SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Organisation Id must be specified");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
// User account.
|
||||
SysId userAccountId = model.MemberUserAccountId.ToSysId();
|
||||
SaxUserAccount userAccount = null;
|
||||
if (!SysId.IsValid(userAccountId) && !StringUtil.IsEmpty(model.MemberUserEmailAddress))
|
||||
{
|
||||
userAccount = AccountMgr.GetUserAccountByEmailAddress(model.MemberUserEmailAddress);
|
||||
disposableItems.Add(userAccount);
|
||||
userAccountId = userAccount?.Id ?? new SysId();
|
||||
}
|
||||
if (!SysId.IsValid(userAccountId))
|
||||
{
|
||||
SaLogger.Warn(fn + " User Account must be identified");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// Retrieve existing item.
|
||||
SysId userOrganisationId = model.UserOrganisationId.ToSysId();
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId);
|
||||
if (userOrganisation == null && SysId.IsValid(userOrganisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user organisation for Id: '" + userOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
if (userOrganisation != null && (!userOrganisation.UserAccountId.Equals(userAccountId) || !userOrganisation.OrganisationId.Equals(organisationId)))
|
||||
{
|
||||
// Either User Account and/or Organisation Ids don't match.
|
||||
SaLogger.Warn(fn + " Inconsistent user organisation properties. UserAccountId: " + userOrganisation.UserAccountId + " vs " + userAccountId + ". OrganisationId: " + userOrganisation.OrganisationId + " vs " + organisationId + ".");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
// Organisation.
|
||||
SysId organisationId = model.MemberOrganisationId.ToSysId();
|
||||
SaxOrganisation organisation = null;
|
||||
if (!SysId.IsValid(organisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Organisation Id must be specified");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.data.incomplete"]));
|
||||
}
|
||||
|
||||
// User Organisation not identified.
|
||||
if (userOrganisation == null)
|
||||
{
|
||||
// See whether user has an 'interest' in the organisation.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = false;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
|
||||
userOrganisation = AccountMgr.GetUserOrganisation(prmUserOrganisation);
|
||||
if (userOrganisation != null)
|
||||
userOrganisation.Status = SaStatus.Active;
|
||||
// Retrieve existing item.
|
||||
SysId userOrganisationId = model.UserOrganisationId.ToSysId();
|
||||
SaxUserOrganisation userOrganisation = AccountMgr.GetUserOrganisationById(userOrganisationId);
|
||||
disposableItems.Add(userOrganisation);
|
||||
if (userOrganisation == null && SysId.IsValid(userOrganisationId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user organisation for Id: '" + userOrganisationId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
if (userOrganisation != null && (!userOrganisation.UserAccountId.Equals(userAccountId) || !userOrganisation.OrganisationId.Equals(organisationId)))
|
||||
{
|
||||
// Either User Account and/or Organisation Ids don't match.
|
||||
SaLogger.Warn(fn + " Inconsistent user organisation properties. UserAccountId: " + userOrganisation.UserAccountId + " vs " + userAccountId + ". OrganisationId: " + userOrganisation.OrganisationId + " vs " + organisationId + ".");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// User Organisation not identified.
|
||||
if (userOrganisation == null)
|
||||
{
|
||||
// See whether user has an 'interest' in the organisation.
|
||||
SaxUserOrganisation.Params prmUserOrganisation = new SaxUserOrganisation.Params();
|
||||
prmUserOrganisation.UserAccountIdsIncluded.Add(userAccountId);
|
||||
prmUserOrganisation.OrganisationIdsIncluded.Add(organisationId);
|
||||
prmUserOrganisation.OrganisationMembersOnly = false;
|
||||
prmUserOrganisation.StatusCat = SaxUserOrganisation.StatusCat.Any;
|
||||
userOrganisation = AccountMgr.GetUserOrganisation(prmUserOrganisation);
|
||||
if (userOrganisation != null)
|
||||
userOrganisation.Status = SaStatus.Active;
|
||||
else
|
||||
// Organisation not found for user.
|
||||
userOrganisation = AccountMgr.CreateUserOrganisation(userAccountId, organisationId);
|
||||
disposableItems.Add(userOrganisation);
|
||||
}
|
||||
|
||||
// Retrieve associated items.
|
||||
if (userAccount == null)
|
||||
{
|
||||
userAccount = AccountMgr.GetUserAccountById(userAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
}
|
||||
if (organisation == null)
|
||||
{
|
||||
organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
disposableItems.Add(organisation);
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
if (model.MemberRoleCodes != null)
|
||||
userOrganisation.OrganisationRoles = SaxUserOrganisation.GetOrganisationRolesFromCodes(model.GetMemberRoleCodes());
|
||||
userOrganisation.AddOrganisationRole(Sax.OrganisationRole.Member);
|
||||
if (model.MemberStatusCode != null)
|
||||
userOrganisation.Status = model.MemberStatus;
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(userOrganisation.Id))
|
||||
{
|
||||
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
// Organisation not found for user.
|
||||
userOrganisation = AccountMgr.CreateUserOrganisation(userAccountId, organisationId);
|
||||
}
|
||||
|
||||
// Retrieve associated items.
|
||||
if (userAccount == null)
|
||||
userAccount = AccountMgr.GetUserAccountById(userAccountId);
|
||||
if (organisation == null)
|
||||
organisation = AccountMgr.GetOrganisationById(organisationId);
|
||||
|
||||
// Populate item properties.
|
||||
if (model.MemberRoleCodes != null)
|
||||
userOrganisation.OrganisationRoles = SaxUserOrganisation.GetOrganisationRolesFromCodes(model.GetMemberRoleCodes());
|
||||
userOrganisation.AddOrganisationRole(Sax.OrganisationRole.Member);
|
||||
if (model.MemberStatusCode != null)
|
||||
userOrganisation.Status = model.MemberStatus;
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(userOrganisation.Id))
|
||||
{
|
||||
if (!AccountMgr.InsertUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert user organisation: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!AccountMgr.UpdateUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(userOrganisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
if (!AccountMgr.UpdateUserOrganisation(userOrganisation, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update user organisation [Id:" + SysId.ToString(userOrganisation.Id) + "]: " + AccountMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + AccountMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
}
|
||||
|
||||
// Construct response.
|
||||
PopulateMemberResponseData(responseData.Member, userOrganisation, userAccount, organisation);
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("System/Ajax/GetDatabaseTables")]
|
||||
public IActionResult Ajax_GetDatabaseTables(Model_Sport model)
|
||||
public IActionResult Ajax_GetDatabaseTables(Model_System model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetDatabaseTables";
|
||||
String messageTitle = Localiser["system.caption.database"];
|
||||
@@ -83,6 +83,10 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
List<DbDfnTable> tableDfns = db.GetTableDfns();
|
||||
foreach (DbDfnTable tableDfn in tableDfns.OrderBy(item => item.Name))
|
||||
{
|
||||
// Filter by table name.
|
||||
if (!StringUtil.IsEmpty(model.DatabaseFilter.Table) && !tableDfn.Name.ContainsCI(model.DatabaseFilter.Table))
|
||||
continue;
|
||||
|
||||
DatabaseTableData tableData = new DatabaseTableData();
|
||||
tableData.SchemaName = tableDfn.Schema;
|
||||
tableData.TableName = tableDfn.Name;
|
||||
|
||||
@@ -211,7 +211,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId userAccountId = model.UserAccountId.ToSysId();
|
||||
SysId userAccountId = model.UserId.ToSysId();
|
||||
if (!SysId.IsValid(userAccountId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
@@ -302,12 +302,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
|
||||
// Retrieve existing item.
|
||||
SysId userAccountId = model.UserAccountId.ToSysId();
|
||||
SysId userAccountId = model.UserId.ToSysId();
|
||||
SaxUserAccount user = AccountMgr.GetUserAccountById(userAccountId);
|
||||
disposableItems.Add(user);
|
||||
if (user == null && SysId.IsValid(userAccountId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user for Id: '" + model.UserAccountId + "'");
|
||||
SaLogger.Warn(fn + " Failed to retrieve user for Id: '" + model.UserId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
@@ -428,12 +428,12 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
|
||||
// Retrieve user.
|
||||
SysId userAccountId = model.UserAccountId.ToSysId();
|
||||
SysId userAccountId = model.UserId.ToSysId();
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
if (userAccount == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve user for Id: '" + model.UserAccountId + "'");
|
||||
SaLogger.Warn(fn + " Failed to retrieve user for Id: '" + model.UserId + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
|
||||
@@ -160,7 +160,7 @@ namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId userAccountId = model.UserAccountId.ToSysId();
|
||||
SysId userAccountId = model.UserId.ToSysId();
|
||||
if (!SysId.IsValid(userAccountId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user