Contacts and Commodities

This commit is contained in:
2021-08-05 20:36:06 +01:00
parent afd38cea03
commit f5e0b925fb
33 changed files with 694 additions and 505 deletions
+2 -39
View File
@@ -1,4 +1,5 @@
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Newtonsoft.Json;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.Net.Standard.Base.Bus;
@@ -26,23 +27,11 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
securityProfile = new SbmSecurityProfile(this, false);
}
//-------------------------------------------------------------------
// User Context.
public SbmUserContext UserContext
{
get
{
SbmUserContext userContext = new SbmUserContext_Web(SessionContext);
return userContext;
}
}
//-------------------------------------------------------------------
// Security Profile.
private readonly SbmSecurityProfile securityProfile;
public ISbmSecurityProfile SecurityProfile { get { return securityProfile; } }
//-------------------------------------------------------------------
// ToDo: Organisation configuration.
public String GetOrganisationOption(Sbm.OrganisationOption option, String context) { return null; }
@@ -61,32 +50,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
public Sbm.CommodityType GetOwnerOption_CommodityType(Sbm.OrgOption_CommodityType commodityTypeContext) { return Sbm.CommodityType.Unknown; }
public SysId GetOwnerOption_StockLocation(Sbm.OrgOption_StockLocation eLoc) { return null; }
//-------------------------------------------------------------------
// Contacts.
public class ContactsData
{
public class FilterData
{
public uint PageNo { get; set; } = 1;
public ushort PageLength { get; set; } = 16;
}
public FilterData Filter { get; } = new FilterData();
}
public ContactsData Contacts { get; } = new ContactsData();
//-------------------------------------------------------------------
// Commodities.
public class CommoditiesData
{
public class FilterData
{
public uint PageNo { get; set; } = 1;
public ushort PageLength { get; set; } = 16;
}
public FilterData Filter { get; } = new FilterData();
}
public CommoditiesData Commodities { get; } = new CommoditiesData();
//-------------------------------------------------------------------
}
//=======================================================================
+3 -1
View File
@@ -109,7 +109,9 @@ namespace Sarand.BusinessMgr.Net.Core.Web.App
.AddViewLocalization(
LanguageViewLocationExpanderFormat.Suffix,
opts => { opts.ResourcesPath = resourcesPath; })
.AddDataAnnotationsLocalization();
.AddDataAnnotationsLocalization()
// Ignore null values during object serisliation.
.AddJsonOptions(options => { options.JsonSerializerOptions.IgnoreNullValues = true; });
// Configure localisation middleware.
config.services.Configure<RequestLocalizationOptions>
@@ -11,6 +11,7 @@ using Sarand.BusinessMgr.Net.Core.Web.Models;
using Sarand.BusinessMgr.Net.Standard.Base.App;
using Sarand.BusinessMgr.Net.Standard.Base.Bus;
using Sarand.BusinessMgr.Net.Standard.Base.Consoles;
using Sarand.BusinessMgr.Net.Standard.Base.Core;
using Sarand.BusinessMgr.Net.Standard.Base.Mgr;
using Sarand.Net.Standard.Base.App;
using Sarand.Net.Standard.Base.CodeTypes;
@@ -69,8 +70,8 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
public bool DebugMode { get; } = SacsSystem.DebugMode;
protected SbmApplication_Web App { get { return SbmGlobals_Web.Application; } }
public SbmAppConfig AppConfig { get { return App.AppConfig; } }
public SbmSessionContext SessionContext { get { return UserContext?.SessionContext ?? null; } }
public SbmUserContext UserContext { get { return SessionData.UserContext; } }
public SbmSessionContext SessionContext { get { return SessionData?.SessionContext ?? null; } }
public ISbmUserContext UserContext { get { return SessionData; } }
protected SbmLocaliser Localiser { get; }
/// <summary>
/// Indicate whether session data should be stored by action.
@@ -386,10 +387,10 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
public class AjaxResponse_Base
{
// Response status.
public bool Success { get; set; } = false;
public bool Error { get; set; } = false;
public bool SessionExpired { get; protected set; } = false;
public bool GoHome { get; protected set; } = false;
public bool? Success { get; set; } = null;
public bool? Error { get; set; } = null;
public bool? SessionExpired { get; protected set; } = null;
public bool? GoHome { get; protected set; } = null;
public AjaxResponse_Base SetSessionExpired(String title, String text)
{
SessionExpired = true;
@@ -432,15 +433,22 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
}
//---------------------------------------------------------------
/// <summary>
/// Common item response data properties.
/// <para>- Null values are ignored by the JSON serialiser.</para>
/// <para>- Return null for false boolean values where possible.</para>
/// <para>- Return null for blank string values where possible.</para>
/// </summary>
public class ItemData
{
public String Id { get; set; }
public String Notes { get; set; }
private String notes;
public String Notes { get { return StringUtil.OnEmpty(notes, null); } set { notes = StringUtil.EmptyOnNull(value).Trim(); } }
public String StatusCode { get; set; }
public String StatusDesc { get; set; }
public Boolean Awaiting { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Awaiting)); } }
public Boolean Active { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Active)); } }
public Boolean Deleted { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Deleted)); } }
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? Deleted { get { return StatusCode.EqualsCI(SacsSystem.GetStatusCode(SaStatus.Deleted)) ? true : (bool?)null; } }
public String CreatedOn { get; set; }
public String CreatedOnFmt { get; set; }
public String UpdatedOn { get; set; }
@@ -462,7 +470,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
public String Error { get; set; }
}
private readonly Dictionary<String, FormControlValue> controlValues = new Dictionary<String, FormControlValue>();
public List<FormControlValue> ControlValues { get { return controlValues.Values.ToList(); } }
public List<FormControlValue> ControlValues { get { return controlValues.Count > 0 ? controlValues.Values.ToList() : null; } }
public void SetControlValue(String controlName, String value, String error = null)
{
if (controlValues.ContainsKey(controlName))
@@ -509,7 +517,6 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Controllers
public String Message { get; set; }
}
public NotificationData Notification { get; private set; }
public bool HasNotification { get { return Notification != null; } }
public AjaxResponse_Data SetNotification(String title, String message)
{
Notification = new NotificationData() { Title = title, Message = message };
+1 -1
View File
@@ -63,7 +63,7 @@ namespace Sarand.BusinessMgr.Net.Core.Web.Models
//-------------------------------------------------------------------
// Business components.
// NB Keep these accessors protected to avoid them being called by teh model binding logic before the session data is ready.
protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(SessionData_Web.UserContext); return internals; } }
protected SbmInternals Internals { get { if (internals == null) internals = new SbmInternals(SessionData_Web); return internals; } }
// Managers.
protected SbmAccountMgr AccountMgr { get { return Internals.AccountMgr; } }
protected SbmAssetMgr AssetMgr { get { return Internals.AssetMgr; } }