Update existing reports, removing mileage drill down
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Data.SqlTypes;
|
||||
@@ -143,21 +144,38 @@ namespace MileageTraker.Web.Utility
|
||||
: propertyMember.Name;
|
||||
}
|
||||
|
||||
public static object GetValue(this PropertyInfo propertyMember, object obj)
|
||||
|
||||
public static string GetNullDisplayText(this PropertyInfo propertyMember, object obj)
|
||||
{
|
||||
var value = propertyMember.GetValue(obj, null);
|
||||
var displayAttr =
|
||||
propertyMember.GetCustomAttributes(typeof (DisplayFormatAttribute), true).FirstOrDefault() as DisplayFormatAttribute;
|
||||
var displayAttr = GetDisplayAttribute(propertyMember);
|
||||
|
||||
if (displayAttr != null)
|
||||
{
|
||||
if (value == null && !String.IsNullOrEmpty(displayAttr.NullDisplayText))
|
||||
return displayAttr.NullDisplayText;
|
||||
|
||||
if (!String.IsNullOrEmpty(displayAttr.DataFormatString))
|
||||
return String.Format(displayAttr.DataFormatString, value);
|
||||
}
|
||||
return value;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static string GetDataFormatString(this PropertyInfo propertyMember, object obj)
|
||||
{
|
||||
var value = propertyMember.GetValue(obj, null);
|
||||
var displayAttr = GetDisplayAttribute(propertyMember);
|
||||
|
||||
if (displayAttr != null)
|
||||
{
|
||||
if (!String.IsNullOrEmpty(displayAttr.DataFormatString))
|
||||
return displayAttr.DataFormatString;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static DisplayFormatAttribute GetDisplayAttribute(PropertyInfo propertyMember)
|
||||
{
|
||||
var displayAttr =
|
||||
propertyMember.GetCustomAttributes(typeof (DisplayFormatAttribute), true).FirstOrDefault() as DisplayFormatAttribute;
|
||||
return displayAttr;
|
||||
}
|
||||
|
||||
public static IEnumerable<string> GetPropertyNames(this Type type)
|
||||
@@ -293,6 +311,25 @@ namespace MileageTraker.Web.Utility
|
||||
select mg.Key).ToList()
|
||||
}).ToDictionary(arg => arg.Item1, arg => arg.Item2List);
|
||||
}
|
||||
|
||||
public static bool IsNonStringEnumerable(this Type type)
|
||||
{
|
||||
if (type == null || type == typeof(string))
|
||||
return false;
|
||||
return typeof(IEnumerable).IsAssignableFrom(type);
|
||||
}
|
||||
|
||||
public static bool IsHiddenFromModel(this MemberInfo propertyMember)
|
||||
{
|
||||
var hiddenInputAttribute =
|
||||
propertyMember.GetCustomAttributes(typeof(HiddenInputAttribute), true).FirstOrDefault() as HiddenInputAttribute;
|
||||
|
||||
if (hiddenInputAttribute != null)
|
||||
{
|
||||
return !hiddenInputAttribute.DisplayValue;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//public static IEnumerable<SelectListItem> ToSelectList<T>(
|
||||
// this IEnumerable<T> enumerable,
|
||||
|
||||
Reference in New Issue
Block a user