v1.2.10.5
This commit is contained in:
@@ -14,6 +14,8 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers
|
||||
{
|
||||
//=======================================================================
|
||||
// Sport Controller - Ajax requests.
|
||||
//=======================================================================
|
||||
partial class SportController
|
||||
{
|
||||
|
||||
@@ -0,0 +1,351 @@
|
||||
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.Standard.Base.App;
|
||||
using Saxonite.Net.Core.Web.Admin.Models;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Support;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Bus.Support;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers.Support
|
||||
{
|
||||
//=======================================================================
|
||||
// UserReport Controller - Ajax requests.
|
||||
//=======================================================================
|
||||
partial class Controller_UserReport
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// UserReport data.
|
||||
private class UserReportListData : AjaxResponse_Data.ItemData_Base
|
||||
{
|
||||
// Account Id only populated while account names are being queried, then nulled.
|
||||
public SysId UserAccountId { get; set; }
|
||||
public String UserDisplayName { get; set; }
|
||||
public String ReportTypeCode { get; set; }
|
||||
public String ReportTypeDesc { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String RecordedOnDisp { get; set; }
|
||||
}
|
||||
private class UserReportItemData : UserReportListData
|
||||
{
|
||||
public String ReportType { get; set; }
|
||||
public String Report { get; set; }
|
||||
public String RecordedOnForm { get; set; }
|
||||
}
|
||||
private void PopulateUserReportResponseListData(SaxModel_Admin model, SaxUserReport userReport, SaxUserAccount userAccount, UserReportListData data)
|
||||
{
|
||||
data.Id = SysId.ToString(userReport.Id);
|
||||
data.UserDisplayName = userAccount.GetDisplayName();
|
||||
data.ReportTypeCode = UserReportTypeCodes.GetCodeForType(userReport.ReportType);
|
||||
data.ReportTypeDesc = model.Localiser.GetUserReportTypeCaption(userReport.ReportType);
|
||||
data.Title = userReport.Title;
|
||||
data.RecordedOnDisp = model.FormatDateForDisplay(userReport.RecordedOn);
|
||||
data.StatusCode = userReport.StatusCode;
|
||||
data.StatusDesc = userReport.StatusDesc;
|
||||
}
|
||||
private void PopulateUserReportResponseItemData(Model_UserReport model, SaxUserReport userReport, SaxUserAccount userAccount, UserReportItemData data)
|
||||
{
|
||||
PopulateUserReportResponseListData(model, userReport, userAccount, data);
|
||||
data.Report = userReport.Report;
|
||||
data.RecordedOnForm = model.FormatDateForForm(userReport.RecordedOn);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Ajax - User Report list.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_UserReportList : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_UserReportList(SaxModel_Admin model) : base(model) { }
|
||||
// UserReport list.
|
||||
public List<UserReportListData> Reports { get; } = new List<UserReportListData>();
|
||||
// Reference data.
|
||||
public List<ItemCodeDesc> ReportTypes { get; } = new List<ItemCodeDesc>();
|
||||
public List<ItemCodeDesc> Statuses { get; } = new List<ItemCodeDesc>();
|
||||
public String DefaultStatusCode { get; set; }
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("UserReport/Ajax/GetList")]
|
||||
public IActionResult Ajax_GetList(Model_UserReport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetList";
|
||||
String messageTitle = Localiser["caption.user.reports"];
|
||||
AjaxResponse_UserReportList responseData = new AjaxResponse_UserReportList(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Reference data - report types.
|
||||
responseData.ReportTypes.Add(new AjaxResponse_Data.ItemCodeDesc());
|
||||
List<Sax.UserReportType> validReportTypes = new List<Sax.UserReportType>(EnumUtil.GetValues<Sax.UserReportType>());
|
||||
foreach (TypeCodeDesc reportType in UserReportTypeCodes)
|
||||
{
|
||||
if (!validReportTypes.Contains((Sax.UserReportType)reportType.Type)) continue;
|
||||
responseData.ReportTypes.Add(new AjaxResponse_Data.ItemCodeDesc() { Code = reportType.Code, Desc = Localiser.GetUserReportTypeCaption((Sax.UserReportType)reportType.Type) });
|
||||
}
|
||||
|
||||
// Reference data - statuses.
|
||||
foreach (SaStatus status in SaxUserReport.ValidStatuses.FindAll(item => item != SaStatus.Deleted))
|
||||
responseData.Statuses.Add(new AjaxResponse_Data.ItemCodeDesc() { Code = SacsSystem.GetStatusCode(status), Desc = Localiser.GetStatusCaption(status) });
|
||||
responseData.DefaultStatusCode = SacsSystem.GetStatusCode(SaxUserReport.DefaultStatus);
|
||||
|
||||
// Item filter.
|
||||
SaxUserReport.Params prmUserReport = new SaxUserReport.Params();
|
||||
prmUserReport.UserReportFilter = model.Filter.Report;
|
||||
prmUserReport.StatusCat = SaxUserReport.StatusCat.NotDeleted;
|
||||
model.Paging.ItemTotal = (ulong)SupportMgr.GetUserReportCount(prmUserReport);
|
||||
model.PopulatePagingTo(prmUserReport.ResultsPaging);
|
||||
|
||||
// Item columns.
|
||||
ColumnDfn colId = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Id);
|
||||
ColumnDfn colUserAccountId = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.UserAccountId);
|
||||
ColumnDfn colReportType = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.ReportType);
|
||||
ColumnDfn colTitle = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Title);
|
||||
ColumnDfn colRecordedOn = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.RecordedOn);
|
||||
ColumnDfn colStatus = SupportMgr.GetUserReportColumnDfn(SaxUserReport.Column.Status);
|
||||
List<ColumnDfn> columns = new List<ColumnDfn>()
|
||||
{
|
||||
colId, colUserAccountId, colReportType, colTitle,
|
||||
colRecordedOn, colStatus
|
||||
};
|
||||
|
||||
// Sort order.
|
||||
prmUserReport.SortColumns.Add(colRecordedOn);
|
||||
prmUserReport.SortColumns.Last().SortAscending = false;
|
||||
prmUserReport.SortColumns.Add(colId);
|
||||
prmUserReport.SortColumns.Last().SortAscending = false;
|
||||
|
||||
// User account details must be queried separately - different database!
|
||||
HashSet<SysId> userAccountIds = new HashSet<SysId>();
|
||||
|
||||
// Query items.
|
||||
using (DbResultSet resultSet = SupportMgr.ExecuteUserReportQuery(columns, prmUserReport))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
SysId userAccountId = new SysId(values.GetLong(colUserAccountId.DataName));
|
||||
userAccountIds.AddId(userAccountId);
|
||||
Sax.UserReportType reportType = (Sax.UserReportType)values.GetLong(colReportType.DataName);
|
||||
UserReportListData userReportData = new UserReportListData()
|
||||
{
|
||||
Id = values.GetString(colId.DataName),
|
||||
UserAccountId = userAccountId,
|
||||
ReportTypeCode = UserReportTypeCodes.GetCodeForType(reportType),
|
||||
ReportTypeDesc = model.Localiser.GetUserReportTypeCaption(reportType),
|
||||
Title = values.GetString(colTitle.DataName),
|
||||
RecordedOnDisp = model.FormatDateForDisplay(values.GetDate(colRecordedOn.DataName)),
|
||||
StatusCode = values.GetString(colStatus.DataName),
|
||||
StatusDesc = SacsSystem.GetStatusDescForCode(values.GetString(colStatus.DataName))
|
||||
};
|
||||
responseData.Reports.Add(userReportData);
|
||||
}
|
||||
}
|
||||
if (model.Paging.IsPaged)
|
||||
model.Paging.ItemCount = (ushort)responseData.Reports.Count;
|
||||
|
||||
// Query and populate User Account details.
|
||||
if (userAccountIds.Any())
|
||||
{
|
||||
// User Account columns.
|
||||
ColumnDfn colUserAccount_Id = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Id);
|
||||
ColumnDfn colUserAccount_Title = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.Title);
|
||||
ColumnDfn colUserAccount_FirstName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.FirstName);
|
||||
ColumnDfn colUserAccount_LastName = AccountMgr.GetUserAccountColumnDfn(SaxUserAccount.Column.LastName);
|
||||
List<ColumnDfn> userAccountCols = new List<ColumnDfn>() { colUserAccount_Id, colUserAccount_Title, colUserAccount_FirstName, colUserAccount_LastName };
|
||||
// User Account filter.
|
||||
SaxUserAccount.Params prmUserAccount = new SaxUserAccount.Params();
|
||||
prmUserAccount.IdsIncluded.AddRange(userAccountIds);
|
||||
prmUserAccount.StatusCat = SaxUserAccount.StatusCat.Any;
|
||||
// Query user accounts and populate properties to report list.
|
||||
using (DbResultSet resultSet = AccountMgr.ExecuteUserAccountQuery(userAccountCols, prmUserAccount))
|
||||
{
|
||||
while (resultSet != null && resultSet.HasRows && resultSet.NextRecord())
|
||||
{
|
||||
NamedValue.Map values = resultSet.GetRecordValues();
|
||||
SysId userAccountId = new SysId(values.GetLong(colUserAccount_Id.DataName));
|
||||
String title = values.GetString(colUserAccount_Title.DataName);
|
||||
String firstName = values.GetString(colUserAccount_FirstName.DataName);
|
||||
String lastName = values.GetString(colUserAccount_LastName.DataName);
|
||||
foreach (UserReportListData userReportData in responseData.Reports.FindAll(item => SysId.InvalidOnNull(item.UserAccountId).Equals(userAccountId)))
|
||||
{
|
||||
userReportData.UserDisplayName = SaxUserAccount.GetDisplayName(title, firstName, lastName);
|
||||
userReportData.UserAccountId = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear any remaining User Account Ids.
|
||||
foreach (UserReportListData userReportData in responseData.Reports.FindAll(item => item.UserAccountId != null))
|
||||
userReportData.UserAccountId = null;
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.SetPaging(model);
|
||||
responseData.Success = true;
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Ajax - User Report properties.
|
||||
//-------------------------------------------------------------------
|
||||
private class AjaxResponse_UserReport : AjaxResponse_Data
|
||||
{
|
||||
// Construction.
|
||||
public AjaxResponse_UserReport(SaxModel_Admin model) : base(model) { }
|
||||
// UserReport details.
|
||||
public UserReportItemData Report { get; } = new UserReportItemData();
|
||||
}
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("UserReport/Ajax/GetItem")]
|
||||
public IActionResult Ajax_GetItem(Model_UserReport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_GetItem";
|
||||
String messageTitle = Localiser["caption.user.report"];
|
||||
AjaxResponse_UserReport responseData = new AjaxResponse_UserReport(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Identify item.
|
||||
SysId userReportId = model.UserReport.Id.ToSysId();
|
||||
if (!SysId.IsValid(userReportId))
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.specified"]));
|
||||
|
||||
// Retrieve item.
|
||||
SaxUserReport userReport = SupportMgr.GetUserReportById(userReportId);
|
||||
disposableItems.Add(userReport);
|
||||
if (userReport == null)
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve userReport for Id: '" + model.UserReport.Id + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Retrieve user.
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userReport.UserAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserReportResponseItemData(model, userReport, userAccount, responseData.Report);
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Ajax - User Report storage.
|
||||
//-------------------------------------------------------------------
|
||||
[HttpPost]
|
||||
[Route("UserReport/Ajax/StoreItem")]
|
||||
public IActionResult Ajax_StoreItem(Model_UserReport model)
|
||||
{
|
||||
String fn = GetType().Name + ".Ajax_StoreItem";
|
||||
String messageTitle = Localiser["caption.user.report"];
|
||||
AjaxResponse_UserReport responseData = new AjaxResponse_UserReport(model);
|
||||
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return GetAjaxResult_InvalidSession(responseData);
|
||||
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
|
||||
// Validate item properties.
|
||||
model.ValidateUserReportData(responseData);
|
||||
if (responseData.HasControlErrors())
|
||||
return Json(responseData);
|
||||
|
||||
// Retrieve existing item.
|
||||
SysId userReportId = model.UserReport.Id.ToSysId();
|
||||
if (StringUtil.ToBool(model.UserReport.Exists) && !SysId.IsValid(userReportId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Item Id not supplied for existing item.");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
if (!StringUtil.ToBool(model.UserReport.Exists) && SysId.IsValid(userReportId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Item Id supplied for new item: '" + model.UserReport.Id + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.system"]));
|
||||
}
|
||||
SaxUserReport userReport = SupportMgr.GetUserReportById(userReportId);
|
||||
disposableItems.Add(userReport);
|
||||
if (userReport == null && SysId.IsValid(userReportId))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to retrieve userReport for Id: '" + model.UserReport.Id + "'");
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.id.not.found"]));
|
||||
}
|
||||
|
||||
// Create new item if required.
|
||||
if (userReport == null)
|
||||
{
|
||||
userReport = SupportMgr.CreateUserReport(SessionUserAccountId);
|
||||
disposableItems.Add(userReport);
|
||||
userReport.RecordedOn = DateTime.Today;
|
||||
}
|
||||
|
||||
// Populate item properties.
|
||||
if (model.UserReport.ReportType != null)
|
||||
userReport.ReportType = model.UserReportType;
|
||||
if (model.UserReport.Title != null)
|
||||
userReport.Title = model.UserReport.Title;
|
||||
if (model.UserReport.Report != null)
|
||||
userReport.Report = model.UserReport.Report;
|
||||
if (model.UserReport.Status != null)
|
||||
userReport.Status = model.UserReportStatus;
|
||||
|
||||
// Store item.
|
||||
if (!SysId.IsValid(userReport.Id))
|
||||
{
|
||||
if (!SupportMgr.InsertUserReport(userReport, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to insert userReport: " + SupportMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.insert.failed"] + "\n\n" + SupportMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!SupportMgr.UpdateUserReport(userReport, DbUpdateInfo))
|
||||
{
|
||||
SaLogger.Warn(fn + " Failed to update userReport [Id:" + SysId.ToString(userReport.Id) + "]: " + SupportMgr.ErrorStateMessage);
|
||||
return Json(responseData.SetMessage(messageTitle, Localiser["msg.error.item.update.failed"] + "\n\n" + SupportMgr.ErrorStateMessage));
|
||||
}
|
||||
}
|
||||
|
||||
// Retrieve user.
|
||||
SaxUserAccount userAccount = AccountMgr.GetUserAccountById(userReport.UserAccountId);
|
||||
disposableItems.Add(userAccount);
|
||||
|
||||
// Construct response.
|
||||
PopulateUserReportResponseItemData(model, userReport, userAccount, responseData.Report);
|
||||
}
|
||||
|
||||
// Complete response.
|
||||
responseData.Success = true;
|
||||
|
||||
return Json(responseData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Support;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public partial class Controller_UserReport : SaxController_Admin_Support
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public Controller_UserReport(SaxLocaliser localiser, ILogger<HomeController> logger) :
|
||||
base(localiser, logger)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Index page.
|
||||
[HttpGet]
|
||||
[Route("UserReport")]
|
||||
[Route("UserReport/Index")]
|
||||
public IActionResult Index(String sta)
|
||||
{
|
||||
// Validate session.
|
||||
if (!ValidUserSession)
|
||||
return RedirectToAction("", "");
|
||||
|
||||
// Model.
|
||||
Model_UserReport model = new Model_UserReport(Localiser);
|
||||
|
||||
return View("/Views/UserReport/Index.cshtml", model);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Saxonite.Net.Core.Web.Admin.Models.Support;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Controllers.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public abstract class SaxController_Admin_Support : SaxController_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxController_Admin_Support(SaxLocaliser localiser, ILogger<HomeController> logger) :
|
||||
base(localiser, logger)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace Saxonite.Net.Core.Web.Admin.Models
|
||||
//-------------------------------------------------------------------
|
||||
// Session.
|
||||
public SaxSessionData_Admin SessionData_Admin { get { return SessionData as SaxSessionData_Admin; } }
|
||||
public SysId UserAccountId { get { return SessionData_Admin?.User?.UserAccountId ?? null; } }
|
||||
public SysId SessionUserAccountId { get { return SessionData_Admin?.User?.UserAccountId ?? null; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Reference data.
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Bus;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Bus.Support;
|
||||
using System;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Models.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public class Model_UserReport : SaxModel_Admin_Support
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Construction.
|
||||
public Model_UserReport(SaxLocaliser localiser) :
|
||||
base(localiser)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// User Report list configuration.
|
||||
public class FilterData
|
||||
{
|
||||
public String Report { get; set; }
|
||||
}
|
||||
public FilterData Filter { get; } = new FilterData();
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Sport properties.
|
||||
public class UserReportData
|
||||
{
|
||||
public String Id { get; set; }
|
||||
public String Exists { get; set; }
|
||||
public String ReportType { get; set; }
|
||||
public String Title { get; set; }
|
||||
public String Report { get; set; }
|
||||
public String Status { get; set; }
|
||||
}
|
||||
public UserReportData UserReport { get; } = new UserReportData();
|
||||
public Sax.UserReportType UserReportType{ get { return (Sax.UserReportType)UserReportTypeCodes.GetTypeForCode(UserReport.ReportType); } }
|
||||
public SaStatus UserReportStatus { get { return SacsSystem.GetStatusForCode(UserReport.Status); } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Validation.
|
||||
//-------------------------------------------------------------------
|
||||
// User Report.
|
||||
public bool ValidateUserReportData(SaxController_Base.AjaxResponse_Data responseData)
|
||||
{
|
||||
// Record disposable items as they are created so all can be disposed when needed.
|
||||
using (DisposableCollection<SacsHierarchyItem> disposableItems = new DisposableCollection<SacsHierarchyItem>())
|
||||
{
|
||||
// Report Type.
|
||||
String controlName = "UserReportType";
|
||||
if (UserReport.ReportType != null)
|
||||
{
|
||||
if (StringUtil.IsEmpty(UserReport.ReportType))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (UserReportType <= 0)
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
// Report Title.
|
||||
controlName = "UserReportTitle";
|
||||
if (UserReport.Title != null)
|
||||
{
|
||||
responseData.SetControlValue(controlName, UserReport.Title);
|
||||
if (StringUtil.IsEmpty(UserReport.Title))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (StringUtil.GetLength(UserReport.Title) > GetControlMaxLength(SaxDbDfn_Support.ColumnIdx.UserReport_Title))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.maximum.length", GetControlMaxLength(SaxDbDfn_Support.ColumnIdx.UserReport_Title)]);
|
||||
}
|
||||
|
||||
// Status.
|
||||
controlName = "UserReportStatus";
|
||||
if (UserReport.Status != null)
|
||||
{
|
||||
if (StringUtil.IsEmpty(UserReport.Status))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.mandatory.value"]);
|
||||
else if (!SaxUserReport.ValidStatuses.Contains(UserReportStatus))
|
||||
responseData.SetControlError(controlName, Localiser["msg.validation.invalid.value"]);
|
||||
}
|
||||
|
||||
}
|
||||
return !responseData.HasControlErrors();
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Admin.Models.Support
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaxModel_Admin_Support : SaxModel_Admin
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
protected SaxModel_Admin_Support(SaxLocaliser localiser) :
|
||||
base(localiser)
|
||||
{
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Properties.
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
}
|
||||
//=======================================================================
|
||||
}
|
||||
Reference in New Issue
Block a user