BusinessMgr 3.0.1.2
This commit is contained in:
@@ -295,8 +295,20 @@ namespace Sacs.Web.Components
|
||||
{
|
||||
//---------------------------------------------------------------
|
||||
// Construction.
|
||||
protected AjaxResponse_Data(SaModel model)
|
||||
protected AjaxResponse_Data(SaModel model, String messageTitle = "")
|
||||
{
|
||||
if (model.ErrorMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.error", "Error")), model.ErrorMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.WarningMessages.Any())
|
||||
{
|
||||
SetMessage(StringUtil.OnBlank(messageTitle, model.GetText("label.warning", "Warning")), model.WarningMessages.Concat("", "\n"));
|
||||
}
|
||||
else if (model.InfoMessages.Any())
|
||||
{
|
||||
SetNotification(StringUtil.OnBlank(messageTitle, model.GetText("label.notification", "Notificaton")), model.InfoMessages.Concat("", "\n"));
|
||||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Abstractions;
|
||||
using Microsoft.AspNetCore.Mvc.Rendering;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.CodeTypes;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
@@ -11,7 +14,7 @@ using System.Linq;
|
||||
namespace Sacs.Web.Components
|
||||
{
|
||||
//=======================================================================
|
||||
public class SaModel : SacsDisposable
|
||||
public abstract class SaModel : SacsDisposable
|
||||
{
|
||||
//-------------------------------------------------------------------
|
||||
// Data members.
|
||||
@@ -50,13 +53,26 @@ namespace Sacs.Web.Components
|
||||
/// Views can be registered to avoid multiple inclusions in a page.
|
||||
/// <para>Only generate view content if this method returns true.</para>
|
||||
/// </summary>
|
||||
public bool RegisterView(String viewName)
|
||||
public bool RegisterView(ViewContext viewContext)
|
||||
{
|
||||
#if DEBUG
|
||||
if (registeredViews.Contains(viewName))
|
||||
SaLogger.Warn(this.GetType().Name + ".RegisterView View already registered: " + viewName);
|
||||
#endif
|
||||
return registeredViews.Add(viewName);
|
||||
// View identity.
|
||||
String viewPath = viewContext.ExecutingFilePath;
|
||||
if (StringUtil.IsBlank(viewPath)) return false;
|
||||
|
||||
// Action identity.
|
||||
Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor controllerActionDescriptor = viewContext.ActionDescriptor as Microsoft.AspNetCore.Mvc.Controllers.ControllerActionDescriptor;
|
||||
String actionName = viewContext.ActionDescriptor.DisplayName;
|
||||
if (controllerActionDescriptor != null)
|
||||
actionName = $"{controllerActionDescriptor.ControllerName}.{controllerActionDescriptor.ActionName}";
|
||||
|
||||
// Check if view already registered.
|
||||
if (registeredViews.Contains(viewPath))
|
||||
{
|
||||
SaLogger.Debug($"{SysUtil.Fn} View already registered: {viewPath}. Action: {actionName}.");
|
||||
return false;
|
||||
}
|
||||
// Attempt to add this view to those registered on this page, returning false if already registered.
|
||||
return registeredViews.Add(viewPath);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
@@ -131,6 +147,10 @@ namespace Sacs.Web.Components
|
||||
return new SelectList(Enumerable.Empty<SelectListItem>());
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Text & localisation.
|
||||
public abstract String GetText(String textKey, String defaultText);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Messages.
|
||||
//-------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user