init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
15
KretaWeb/ModelBinder/Mvc/AlapdokumentumFileUploadBinder.cs
Normal file
15
KretaWeb/ModelBinder/Mvc/AlapdokumentumFileUploadBinder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
32
KretaWeb/ModelBinder/Mvc/DecimalModelBinder.cs
Normal file
32
KretaWeb/ModelBinder/Mvc/DecimalModelBinder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
32
KretaWeb/ModelBinder/Mvc/DoubleModelBinder.cs
Normal file
32
KretaWeb/ModelBinder/Mvc/DoubleModelBinder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
32
KretaWeb/ModelBinder/Mvc/IntegerModelBinder.cs
Normal file
32
KretaWeb/ModelBinder/Mvc/IntegerModelBinder.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
15
KretaWeb/ModelBinder/Mvc/StringTrimModelBinder.cs
Normal file
15
KretaWeb/ModelBinder/Mvc/StringTrimModelBinder.cs
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue