diff --git a/Web/Controllers/LogController.cs b/Web/Controllers/LogController.cs index 5a6310f..9135721 100644 --- a/Web/Controllers/LogController.cs +++ b/Web/Controllers/LogController.cs @@ -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(); diff --git a/Web/Models/Vehicle.cs b/Web/Models/Vehicle.cs index 603bafd..92cabd8 100644 --- a/Web/Models/Vehicle.cs +++ b/Web/Models/Vehicle.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using System.Web.Mvc; using MileageTraker.Web.Utility; namespace MileageTraker.Web.Models diff --git a/Web/Utility/CustomExtensions.cs b/Web/Utility/CustomExtensions.cs index 2ec270f..129ef3d 100644 --- a/Web/Utility/CustomExtensions.cs +++ b/Web/Utility/CustomExtensions.cs @@ -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(this Enum enumeration) where T : Attribute + private static T GetAttribute(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 ToSelectList(this Type enumType, string selectedItem, string noItemSelected) { var items = (from item in Enum.GetValues(enumType).OfType() 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(Expression> 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 type) - { - return typeof(T).GetProperties(); - } - + public static bool IsBlackBerry(this HttpRequestBase request) { //return true;