Code cleanup
This commit is contained in:
@@ -18,7 +18,7 @@ namespace MileageTraker.Web.Controllers
|
||||
var logs = _dataService.GetLogs();
|
||||
|
||||
var validLogYears = _dataService.GetValidLogYears().ToList();
|
||||
if (validLogYears.Count() == 0)
|
||||
if (!validLogYears.Any())
|
||||
return View("Empty");
|
||||
if (!query.Year.HasValue)
|
||||
query.Year = validLogYears.FirstOrDefault();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Mvc;
|
||||
using MileageTraker.Web.Utility;
|
||||
|
||||
namespace MileageTraker.Web.Models
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Web;
|
||||
@@ -18,7 +16,7 @@ namespace MileageTraker.Web.Utility
|
||||
return str.Aggregate(string.Empty, (current, c) => current + (char.IsUpper(c) ? " " + c : c.ToString()));
|
||||
}
|
||||
|
||||
public static T GetAttribute<T>(this Enum enumeration) where T : Attribute
|
||||
private static T GetAttribute<T>(this Enum enumeration) where T : Attribute
|
||||
{
|
||||
var type = enumeration.GetType();
|
||||
var memInfo = type.GetMember(enumeration.ToString());
|
||||
@@ -59,7 +57,7 @@ namespace MileageTraker.Web.Utility
|
||||
});
|
||||
}
|
||||
|
||||
public static SelectList ToSelectList(this Type enumType, string selectedItem, string noItemSelected)
|
||||
public static IEnumerable<SelectListItem> ToSelectList(this Type enumType, string selectedItem, string noItemSelected)
|
||||
{
|
||||
var items = (from item in Enum.GetValues(enumType).OfType<Enum>()
|
||||
let title = item.GetDisplayName()
|
||||
@@ -72,13 +70,7 @@ namespace MileageTraker.Web.Utility
|
||||
|
||||
return new SelectList(new[]{new SelectListItem{Text = noItemSelected}}.Concat(items), "Value", "Text");
|
||||
}
|
||||
|
||||
public static string GetPropertyName<T>(Expression<Func<T>> expression)
|
||||
{
|
||||
var propertyExpression = (MemberExpression)expression.Body;
|
||||
return propertyExpression.Member.GetName();
|
||||
}
|
||||
|
||||
|
||||
public static string GetName(this MemberInfo propertyMember)
|
||||
{
|
||||
var displayAttr = propertyMember.GetCustomAttributes(typeof(DisplayAttribute), true).FirstOrDefault() as DisplayAttribute;
|
||||
@@ -103,7 +95,6 @@ namespace MileageTraker.Web.Utility
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static string ToVerboseStringHistoric(this TimeSpan ts)
|
||||
{
|
||||
if (ts.TotalDays == 0)
|
||||
@@ -145,12 +136,7 @@ namespace MileageTraker.Web.Utility
|
||||
sb.Append(" ago");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static PropertyInfo[] GetProperties<T>(T type)
|
||||
{
|
||||
return typeof(T).GetProperties();
|
||||
}
|
||||
|
||||
|
||||
public static bool IsBlackBerry(this HttpRequestBase request)
|
||||
{
|
||||
//return true;
|
||||
|
||||
Reference in New Issue
Block a user