v1.1.4.1
This commit is contained in:
@@ -137,6 +137,7 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
//-------------------------------------------------------------------
|
||||
private class CodeCache
|
||||
{
|
||||
public List<TypeCodeDesc> genderCodes;
|
||||
public List<TypeCodeDesc> sportParticipationCodes;
|
||||
public List<TypeCodeDesc> sportOfficiatingCodes;
|
||||
public List<TypeCodeDesc> regionTypeCodes;
|
||||
@@ -155,6 +156,16 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
return SacsSystem.GetStatusDesc(status);
|
||||
}
|
||||
|
||||
// Gender.
|
||||
public String GetGenderCaption(Sax.Gender gender)
|
||||
{
|
||||
if ((int)gender < 1) return "";
|
||||
if (codes.genderCodes == null)
|
||||
codes.genderCodes = SaxSystem.GetCodesOfType(Sax.CodeType.Gender);
|
||||
// ToDo Opportunity Type localisation.
|
||||
return codes.genderCodes.GetDescForType(gender);
|
||||
}
|
||||
|
||||
// Sport Participation.
|
||||
public String GetSportParticipationTypeCaption(Sax.SportParticipation participation)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,7 @@ using Microsoft.AspNetCore.Mvc.Razor;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Microsoft.Net.Http.Headers;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -160,6 +161,10 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
//config.app.UseAuthorization();
|
||||
config.app.UseAntiforgeryTokens();
|
||||
|
||||
// Localisation.
|
||||
IOptions<RequestLocalizationOptions> localizationOptions = config.app.ApplicationServices.GetService<IOptions<RequestLocalizationOptions>>();
|
||||
config.app.UseRequestLocalization(localizationOptions.Value);
|
||||
|
||||
config.app.UseEndpoints(endpoints =>
|
||||
{
|
||||
endpoints.MapControllerRoute(
|
||||
|
||||
@@ -23,6 +23,7 @@ using Saxonite.Net.Standard.Base.Mgr;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
@@ -70,7 +71,23 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
/// <para>Some actions such as scoring a password's complexity don't need to.</para>
|
||||
/// </summary>
|
||||
public virtual bool StoreSessionData { get; protected set; } = true;
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Culture.
|
||||
private CultureInfo sessionCulture;
|
||||
private CultureInfo RequestCulture { get { return Request.HttpContext.Features.Get<IRequestCultureFeature>().RequestCulture.Culture ?? CultureInfo.InvariantCulture; } }
|
||||
public CultureInfo SessionCulture
|
||||
{
|
||||
get
|
||||
{
|
||||
if (sessionCulture == null)
|
||||
{
|
||||
sessionCulture = RequestCulture;
|
||||
// ToDo Adjust culture if needed.
|
||||
}
|
||||
return sessionCulture;
|
||||
}
|
||||
}
|
||||
private string LanguageIso2
|
||||
{
|
||||
get
|
||||
@@ -79,6 +96,8 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
return feature.RequestCulture.UICulture.TwoLetterISOLanguageName.ToLower();
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Business components.
|
||||
public SaxInternals Internals { get { if (internals == null) internals = new SaxInternals(SessionContext); return internals; } }
|
||||
// Consoles.
|
||||
@@ -191,6 +210,7 @@ namespace Saxonite.Net.Core.Web.Base.Controllers
|
||||
if (model == null) return;
|
||||
|
||||
// Session data.
|
||||
model.Controller = this;
|
||||
model.SessionData = SessionData;
|
||||
|
||||
// Redirect locations.
|
||||
|
||||
@@ -6,12 +6,14 @@ using Sarand.Net.Standard.Base.Dbas;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.App;
|
||||
using Saxonite.Net.Core.Web.Base.Controllers;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
using Saxonite.Net.Standard.Base.Bus;
|
||||
using Saxonite.Net.Standard.Base.Consoles;
|
||||
using Saxonite.Net.Standard.Base.Mgr;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Saxonite.Net.Core.Web.Base.Models
|
||||
{
|
||||
@@ -38,11 +40,15 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
protected SaxAppConfig AppConfig { get { return App.AppConfig; } }
|
||||
protected SaxSystem_Web System { get { return App.System_Web; } }
|
||||
public String SessionCookieName { get { return App.SessionCookieName; } }
|
||||
public SaxLocaliser Localiser { get; }
|
||||
public bool DebugMode { get { return SaxSystem.DebugMode; } }
|
||||
// Session properties.
|
||||
public SaxSessionData SessionData { get; set; }
|
||||
public SaxSessionContext SessionContext { get { return SessionData?.SessionContext ?? App.SessionContext; } }
|
||||
public DbUpdateInfo DbUpdateInfo { get { return SessionData?.DbUpdateInfo ?? new DbUpdateInfo(null, "", SaxSystem.ComputerName); } }
|
||||
public bool DebugMode { get { return SaxSystem.DebugMode; } }
|
||||
public SaxLocaliser Localiser { get; }
|
||||
// Request properties.
|
||||
public SaxController_Base Controller { get; set; }
|
||||
public CultureInfo SessionCulture { get { return Controller?.SessionCulture ?? CultureInfo.InvariantCulture; } }
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Page configuration.
|
||||
@@ -190,11 +196,11 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
}
|
||||
public String FormatDateForForm(DateTime value)
|
||||
{
|
||||
return DateUtil.Format(value, "dd-MMM-yyyy");
|
||||
return DateUtil.Format(value, "dd-MMM-yyyy", SessionCulture);
|
||||
}
|
||||
public DateTime ParseDateFromForm(String value)
|
||||
{
|
||||
return DateUtil.ParseExact(value, "dd-MMM-yyyy");
|
||||
return DateUtil.ParseExact(value, "dd-MMM-yyyy", SessionCulture);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user