init
This commit is contained in:
commit
e124a47765
19374 changed files with 9806149 additions and 0 deletions
17
KretaWeb/Attributes/KretaDisplayNameAttribute.cs
Normal file
17
KretaWeb/Attributes/KretaDisplayNameAttribute.cs
Normal file
|
@ -0,0 +1,17 @@
|
|||
using System.ComponentModel;
|
||||
using Kreta.BusinessLogic.Utils;
|
||||
|
||||
namespace Kreta.Web.Attributes
|
||||
{
|
||||
public class KretaDisplayNameAttribute : DisplayNameAttribute
|
||||
{
|
||||
public KretaDisplayNameAttribute(int resourceId)
|
||||
: base(GetMessageFromResource(resourceId))
|
||||
{ }
|
||||
|
||||
private static string GetMessageFromResource(int resourceId)
|
||||
{
|
||||
return StringResourcesUtils.GetString(resourceId);
|
||||
}
|
||||
}
|
||||
}
|
28
KretaWeb/Attributes/KretaGlobalLanguageChangeActionFilter.cs
Normal file
28
KretaWeb/Attributes/KretaGlobalLanguageChangeActionFilter.cs
Normal file
|
@ -0,0 +1,28 @@
|
|||
using System.Globalization;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Mvc;
|
||||
|
||||
namespace Kreta.Web.Attributes
|
||||
{
|
||||
public class KretaGlobalLanguageChangeActionFilter : ActionFilterAttribute
|
||||
{
|
||||
public string LanguageCode { get; set; }
|
||||
|
||||
public override void OnActionExecuting(ActionExecutingContext filterContext)
|
||||
{
|
||||
CultureInfo.CurrentCulture = new CultureInfo(LanguageCode);
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(LanguageCode);
|
||||
}
|
||||
}
|
||||
|
||||
public class KretaGlobalLanguageChangeApiActionFilter : System.Web.Http.Filters.ActionFilterAttribute
|
||||
{
|
||||
public string LanguageCode { get; set; }
|
||||
|
||||
public override void OnActionExecuting(HttpActionContext filterContext)
|
||||
{
|
||||
CultureInfo.CurrentCulture = new CultureInfo(LanguageCode);
|
||||
CultureInfo.CurrentUICulture = new CultureInfo(LanguageCode);
|
||||
}
|
||||
}
|
||||
}
|
19
KretaWeb/Attributes/KretaGlobalValidationFilter.cs
Normal file
19
KretaWeb/Attributes/KretaGlobalValidationFilter.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http.Filters;
|
||||
|
||||
namespace Kreta.Web.Attributes
|
||||
{
|
||||
public class KretaGlobalValidationFilter : ActionFilterAttribute
|
||||
{
|
||||
public override void OnActionExecuting(System.Web.Http.Controllers.HttpActionContext actionContext)
|
||||
{
|
||||
if (!actionContext.ModelState.IsValid)
|
||||
{
|
||||
actionContext.Response = actionContext
|
||||
.Request
|
||||
.CreateErrorResponse(HttpStatusCode.BadRequest, actionContext.ModelState);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue