Move Saxonite’s projects into a dedicated `Workspace` folder and align the solution with .NET 10 and the current Common workspace. Update encryption integration, test project structure and coverage, and repository guidance and upgrade notes. - Relocate application and library projects while retaining Git rename history. - Split tests into Admin, Online, and Shared projects; add representative behavioral and serialization tests. - Update Common integration, application version, and repository documentation. Application version: 1.3.0 Reviewed-on: #1 Co-authored-by: andy <andy@sarand.com>
144 lines
5.1 KiB
C#
144 lines
5.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using Newtonsoft.Json;
|
|
using Sacs.Web.Components;
|
|
using Sarand.Net.Standard.Base.App;
|
|
using Sarand.Net.Standard.Base.Core;
|
|
using Sarand.Net.Standard.Base.Utils;
|
|
using Saxonite.Net.Core.Web.Base.Controllers;
|
|
using Saxonite.Net.Standard.Base.App;
|
|
|
|
namespace Saxonite.Web.Api.Controllers
|
|
{
|
|
//=======================================================================
|
|
public class SwapiControllerBase : SaxController_Base
|
|
{
|
|
//-------------------------------------------------------------------
|
|
// Definitions.
|
|
|
|
//-------------------------------------------------------------------
|
|
// Response data.
|
|
// Null values are ignored by JSON serialisation.
|
|
// - See Saxonite.Net.Core.Web.Base.App.SaxStartup.ConfigureServices()
|
|
// - Ref. config.services.AddMvc(...).AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
|
|
//-------------------------------------------------------------------
|
|
// Base response data - for simple responses.
|
|
public class ApiResponse_Base
|
|
{
|
|
// Response status.
|
|
public bool? Success { get; set; } = null;
|
|
public bool? Error { get; set; } = null;
|
|
public bool? SessionExpired { get; protected set; } = null;
|
|
public ApiResponse_Base SetSessionExpired(String title, String text)
|
|
{
|
|
SessionExpired = true;
|
|
return SetMessage(title, text);
|
|
}
|
|
// Message - displays alert popup.
|
|
public class MessageData
|
|
{
|
|
public MessageData(String title, String text)
|
|
{
|
|
this.Title = title;
|
|
this.Text = text;
|
|
}
|
|
public String Title { get; }
|
|
public String Text { get; }
|
|
}
|
|
public MessageData? Message { get; private set; }
|
|
public ApiResponse_Base SetMessage(String title, String text)
|
|
{
|
|
if (!StringUtil.IsBlank(text))
|
|
Message = new MessageData(title, text);
|
|
return this;
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
public class ApiResponse_Data : ApiResponse_Base
|
|
{
|
|
//---------------------------------------------------------------
|
|
// Construction.
|
|
protected ApiResponse_Data()
|
|
{
|
|
}
|
|
|
|
//---------------------------------------------------------------
|
|
/// <summary>Item data - Common properties for data items.</summary>
|
|
public class ItemData_Base
|
|
{
|
|
// Common item properties.
|
|
public String? Id { get; set; }
|
|
public String? Notes { get; set; }
|
|
public String? StatusCode { get; set; }
|
|
public String? StatusDesc { get; set; }
|
|
// Flags for common status values.
|
|
// Return true or null so that property is not serialised when false.
|
|
public bool? Awaiting { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Awaiting)) ? true : (bool?)null; } }
|
|
public bool? Active { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Active)) ? true : (bool?)null; } }
|
|
public bool? Inactive { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Inactive)) ? true : (bool?)null; } }
|
|
public bool? Deleted { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Deleted)) ? true : (bool?)null; } }
|
|
/// <summary>Created on date - YYYYMMDD</summary>
|
|
public String? CreatedOn { get; set; }
|
|
/// <summary>Created on date - formatted per locale</summary>
|
|
public String? CreatedOnFmt { get; set; }
|
|
/// <summary>Updated on date - YYYYMMDD</summary>
|
|
public String? UpdatedOn { get; set; }
|
|
/// <summary>Updated on date - formatted per locale</summary>
|
|
public String? UpdatedOnFmt { get; set; }
|
|
}
|
|
/// <summary>Contact Method properties.</summary>
|
|
public class ContactMethodData
|
|
{
|
|
public String? Method { get; set; }
|
|
public String? MethodCaption { get; set; }
|
|
public String? Value { get; set; }
|
|
}
|
|
/// <summary>Address properties.</summary>
|
|
public class AddressData : ItemData_Base
|
|
{
|
|
public String? Line1 { get; set; }
|
|
public String? Line2 { get; set; }
|
|
public String? Line3 { get; set; }
|
|
public String? Town { get; set; }
|
|
public String? RegionIdProvince { get; set; }
|
|
public String? RegionNameProvince { get; set; }
|
|
public String? RegionIdCountry { get; set; }
|
|
public String? RegionNameCountry { get; set; }
|
|
public String? PostalCode { get; set; }
|
|
}
|
|
/// <summary>
|
|
/// Item data with label and value.
|
|
/// </summary>
|
|
public class ItemLabelValue
|
|
{
|
|
public String? Label { get; set; }
|
|
public String? Value { get; set; }
|
|
}
|
|
/// <summary>
|
|
/// Item data with just Id and name.
|
|
/// <para>- Id is String to allow for obfuscated values.</para>
|
|
/// </summary>
|
|
public class ItemIdName
|
|
{
|
|
public String? Id { get; set; }
|
|
public String? Name { get; set; }
|
|
}
|
|
/// <summary>Item code and desc values.</summary>
|
|
public class ItemCodeDesc
|
|
{
|
|
public String? Code { get; set; }
|
|
public String? Desc { get; set; }
|
|
}
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
// Construction.
|
|
protected SwapiControllerBase() : base(null)
|
|
{
|
|
}
|
|
|
|
//-------------------------------------------------------------------
|
|
}
|
|
//=======================================================================
|
|
}
|