Combine layouts

This commit is contained in:
2012-12-24 21:18:41 -05:00
parent c1944f6262
commit 05d1ae4ec6
83 changed files with 845 additions and 1210 deletions
+24
View File
@@ -0,0 +1,24 @@
using System.Linq;
using System.Web.Mvc;
namespace MileageTraker.Web.Attributes
{
public class ActionLogAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext != null)
{
var controller = filterContext.RouteData.Values["controller"].ToString();
var action = filterContext.RouteData.Values["action"].ToString();
var loggerName = string.Format("{0}Controller.{1}", controller, action);
var @params = string.Join(", ", filterContext.ActionParameters.Select(i => i.Key + ": " + i.Value));
var hostAddress = "UserHostAddress: " + filterContext.HttpContext.Request.UserHostAddress;
log4net.LogManager.GetLogger(loggerName).Info(hostAddress + ", " + @params);
}
base.OnActionExecuting(filterContext);
}
}
}
+14
View File
@@ -0,0 +1,14 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace MileageTraker.Web.Attributes
{
public class DenyFutureDateAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
var date = DateTime.Parse(value.ToString());
return date.Date <= DateTime.Today;
}
}
}
@@ -0,0 +1,23 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace MileageTraker.Web.Attributes
{
public class DenyPreviousMonthDateAttribute : ValidationAttribute
{
public override bool IsValid(object value)
{
var date = DateTime.Parse(value.ToString());
return date.Date >= GetCutoff();
}
private static DateTime GetCutoff()
{
var today = DateTime.Today;
return today.AddMonths(-1).AddDays(-today.Day + 1); // last two months
//if (today.Day > 10)
// return today.AddDays(-today.Day); // beginning of this month
//return today.AddMonths(-1).AddDays(-today.Day); // beginning of previous month
}
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace MileageTraker.Web.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class FormatHintAttribute : Attribute
{
public string Text { get; private set; }
public FormatHintAttribute(string text)
{
Text = text;
}
}
}
@@ -0,0 +1,27 @@
using System;
using System.Reflection;
using System.Web.Mvc;
namespace MileageTraker.Web.Attributes
{
/// <summary>
/// Add to actions to use multiple submit buttons (back or save, for example)
/// </summary>
/// <remarks>
/// http://blog.ashmind.com/2010/03/15/multiple-submit-buttons-with-asp-net-mvc-final-solution/
/// </remarks>
public class HttpParamActionAttribute : ActionNameSelectorAttribute
{
public override bool IsValidName(ControllerContext controllerContext, string actionName, MethodInfo methodInfo)
{
if (actionName.Equals(methodInfo.Name, StringComparison.InvariantCultureIgnoreCase))
return true;
if (!actionName.Equals("Action", StringComparison.InvariantCultureIgnoreCase))
return false;
var request = controllerContext.RequestContext.HttpContext.Request;
return request[methodInfo.Name] != null;
}
}
}
+21
View File
@@ -0,0 +1,21 @@
using System;
namespace MileageTraker.Web.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class InputSizeAttribute : Attribute
{
public string Size { get; private set; }
public string ClassName { get { return "input-" + Size.ToLower(); } }
/// <summary>
/// Specify width of input element
/// </summary>
/// <param name="size">mini, small, medium, large, xlarge, xxlarge</param>
public InputSizeAttribute(string size)
{
Size = size;
}
}
}
+9
View File
@@ -0,0 +1,9 @@
using System;
namespace MileageTraker.Web.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class NoEditLabelAttribute : Attribute
{
}
}
+15
View File
@@ -0,0 +1,15 @@
using System;
namespace MileageTraker.Web.Attributes
{
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)]
public class UnitsAttribute : Attribute
{
public string Text { get; private set; }
public UnitsAttribute(string text)
{
Text = text;
}
}
}