Add project files.

This commit is contained in:
Thomas Savine
2020-03-06 16:07:06 +00:00
parent e7b186c7e3
commit 70de9715ce
300 changed files with 43679 additions and 0 deletions
@@ -0,0 +1,44 @@
using Microsoft.AspNetCore.Mvc.ModelBinding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Sarand.Core.Base;
namespace Sarand.OperationsMgr.Web.System
{
//=======================================================================
/// <summary>
/// Maps a browser request to a data object. Default class provides a base implementation of a model binder.
/// <para>Overridden to trim whitespace from input values.</para>
/// </summary>
public class OpnModelBinder : IModelBinder
{
//-------------------------------------------------------------------
// Construction.
public OpnModelBinder ()
{
}
//-------------------------------------------------------------------
public Task BindModelAsync (ModelBindingContext bindingContext)
{
// Ignore selected properties by name.
var modelName = bindingContext.ModelName;
if (modelName == "RetainAllWhiteSpace")
return Task.CompletedTask;
ValueProviderResult valueProviderResult = bindingContext.ValueProvider.GetValue(modelName);
if (valueProviderResult == ValueProviderResult.None)
return Task.CompletedTask;
// Trim text values.
bindingContext.Result = ModelBindingResult.Success(valueProviderResult.FirstValue.TrimAll());
return Task.CompletedTask;
}
//-------------------------------------------------------------------
}
//=======================================================================
}