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
+30 -19
View File
@@ -2,10 +2,10 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using System.Web.Mvc;
using MileageTraker.Web.Models;
namespace MileageTraker.Web.Utility
{
@@ -13,7 +13,10 @@ namespace MileageTraker.Web.Utility
{
public static string Wordify(this string str)
{
return str.Aggregate(string.Empty, (current, c) => current + (char.IsUpper(c) ? " " + c : c.ToString()));
return str.Aggregate(
String.Empty,
(current, c) =>
current + (Char.IsUpper(c) ? " " + c : c.ToString()));
}
private static T GetAttribute<T>(this Enum enumeration) where T : Attribute
@@ -48,13 +51,14 @@ namespace MileageTraker.Web.Utility
public static IEnumerable<SelectListItem> GetSelectListItems(this Enum enumeration)
{
var type = enumeration.GetType();
return Enum.GetValues(type).OfType<Enum>().Select(e =>
new SelectListItem
{
Text = e.GetDisplayName(),
Value = e.ToString(),
Selected = e.Equals(enumeration)
});
return Enum.GetValues(type)
.OfType<Enum>().Select(e =>
new SelectListItem
{
Text = e.GetDisplayName(),
Value = e.ToString(),
Selected = e.Equals(enumeration)
});
}
public static IEnumerable<SelectListItem> ToSelectList(this Type enumType, string selectedItem, string noItemSelected)
@@ -148,12 +152,12 @@ namespace MileageTraker.Web.Utility
public static string LowercaseFirst(string s)
{
// Check for empty string.
if (string.IsNullOrEmpty(s))
if (String.IsNullOrEmpty(s))
{
return string.Empty;
return String.Empty;
}
// Return char and concat substring.
return char.ToLower(s[0]) + s.Substring(1);
return Char.ToLower(s[0]) + s.Substring(1);
}
public static IEnumerable<int> GetNumbers()
@@ -161,15 +165,22 @@ namespace MileageTraker.Web.Utility
var i = 0;
while (true) yield return i++;
}
public static MvcHtmlString Concat(this MvcHtmlString f, MvcHtmlString s)
{
return MvcHtmlString.Create(f.ToString() + s);
}
public static MvcHtmlString Concat(this MvcHtmlString f, string s)
/// <summary>
/// Users with activity date greater than this value are online
/// </summary>
public static DateTime UserOnlineThreshold()
{
return MvcHtmlString.Create(f + s);
return DateTime.UtcNow.Subtract(
TimeSpan.FromMinutes(
Convert.ToDouble(
System.Web.Security.Membership.UserIsOnlineTimeWindow)));
}
public static bool IsOnline(this User user)
{
return user.LastActivityDate != null
&& user.LastActivityDate > UserOnlineThreshold();
}
}
}