Files
Saxonite/Workspace/SaxoniteCoreWebOnline/Online/Controllers/ReferenceController-Ajax-ContactMethods.cs
T
andy 9f22b522df v1.3.0 Restructure Saxonite workspace and upgrade to .NET 10 (#1)
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>
2026-10-16 18:24:16 +01:00

65 lines
2.6 KiB
C#

using Microsoft.AspNetCore.Mvc;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.Utils;
using Saxonite.Net.Core.Web.Base.Models;
using Saxonite.Net.Core.Web.Online.Models;
using Saxonite.Net.Standard.Base.App;
using Saxonite.Net.Standard.Base.Helpers;
using System;
namespace Saxonite.Net.Core.Web.Online.Controllers
{
//=======================================================================
// Online Reference Controller - Contact Method Ajax actions only.
//=======================================================================
partial class ReferenceController
{
//-------------------------------------------------------------------
// Validate Contact Method.
//-------------------------------------------------------------------
private class AjaxResponse_ValidateContactMethod : AjaxResponse_Data
{
public AjaxResponse_ValidateContactMethod(SaxModel_Base model) : base(model) { }
}
[HttpPost]
[Route("Reference/Ajax/ValidateContactMethod")]
public IActionResult Ajax_ValidateContactMethod(Model_ContactMethod model)
{
String fn = GetType().Name + ".Ajax_ValidateContactMethod";
String messageTitle = Localiser["caption.contact.method"];
AjaxResponse_ValidateContactMethod responseData = new AjaxResponse_ValidateContactMethod(model);
// Validate session and referrer.
if (!ValidReferer) return Forbid();
if (!ValidUserSession) return GetAjaxResult_InvalidSession(responseData);
// Validate method.
Sax.ContactMethod method = EnumUtil.ParseEnum(model.ContactMethod, Sax.ContactMethod.Unknown);
if (model.ContactMethod.IsEmpty() || (int)method < 1)
responseData.SetControlError(nameof(model.ContactMethod), Localiser["msg.validation.mandatory.value"]);
// Validate method.
if (model.ContactValue.IsEmpty())
responseData.SetControlError(nameof(model.ContactValue), Localiser["msg.validation.mandatory.value"]);
// Method specific value validation.
if (!SaxContactMethodHelper.IsValidContactMethodValue(method, model.ContactValue))
{
// Log invalid values so that the validation can be adjusted if needed.
SaLogger.Warn(fn + " Invalid contact method value. Mathod: " + method.ToString() + ". Value: " + model.ContactValue);
responseData.SetControlError(nameof(model.ContactValue), Localiser["msg.validation.invalid.value"]);
}
if (responseData.HasControlErrors())
return Json(responseData);
// Complete response.
responseData.Success = true;
return Json(responseData);
}
//-------------------------------------------------------------------
}
//=======================================================================
}