This commit is contained in:
skidoodle 2024-03-13 00:33:46 +01:00
commit e124a47765
19374 changed files with 9806149 additions and 0 deletions

View file

@ -0,0 +1,15 @@
using System.Web.Mvc;
namespace Kreta.Web.ModelBinder.Mvc
{
public class AlapdokumentumFileUploadBinder : DefaultModelBinder
{
public override object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var name = controllerContext.HttpContext.Request.Files.AllKeys[0];
bindingContext.ModelName = name;
var ret = base.BindModel(controllerContext, bindingContext);
return ret;
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Kreta.Web.ModelBinder.Mvc
{
public class DecimalModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var modelState = new ModelState { Value = valueResult };
bindingContext.ModelState[bindingContext.ModelName] = modelState;
object actualValue = null;
if ((valueResult != null) && !(string.IsNullOrWhiteSpace(valueResult.AttemptedValue) && (bindingContext.ModelType == typeof(decimal?))))
{
try
{
actualValue = decimal.Parse(valueResult.AttemptedValue, NumberStyles.Number, CultureInfo.CreateSpecificCulture("hu-HU"));
}
catch (FormatException e)
{
modelState.Errors.Add(e);
}
}
return actualValue;
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Kreta.Web.ModelBinder.Mvc
{
public class DoubleModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var modelState = new ModelState { Value = valueResult };
bindingContext.ModelState[bindingContext.ModelName] = modelState;
object actualValue = null;
if ((valueResult != null) && !(string.IsNullOrWhiteSpace(valueResult.AttemptedValue) && (bindingContext.ModelType == typeof(double?))))
{
try
{
actualValue = double.Parse(valueResult.AttemptedValue, NumberStyles.Number, CultureInfo.CreateSpecificCulture("hu-HU"));
}
catch (FormatException e)
{
modelState.Errors.Add(e);
}
}
return actualValue;
}
}
}

View file

@ -0,0 +1,32 @@
using System;
using System.Globalization;
using System.Web.Mvc;
namespace Kreta.Web.ModelBinder.Mvc
{
public class IntegerModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
ValueProviderResult valueResult = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var modelState = new ModelState { Value = valueResult };
bindingContext.ModelState[bindingContext.ModelName] = modelState;
object actualValue = null;
if ((valueResult != null) && !(string.IsNullOrWhiteSpace(valueResult.AttemptedValue) && (bindingContext.ModelType == typeof(int?))))
{
try
{
actualValue = int.Parse(valueResult.AttemptedValue, NumberStyles.Number, CultureInfo.CreateSpecificCulture("hu-HU"));
}
catch (FormatException e)
{
modelState.Errors.Add(e);
}
}
return actualValue;
}
}
}

View file

@ -0,0 +1,15 @@
using System.Web.Mvc;
namespace Kreta.Web.ModelBinder.Mvc
{
public class StringTrimModelBinder : IModelBinder
{
public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
{
var value = bindingContext.ValueProvider.GetValue(bindingContext.ModelName);
var attemptedValue = value?.AttemptedValue;
return string.IsNullOrWhiteSpace(attemptedValue) ? null : attemptedValue.Trim();
}
}
}