Update existing reports, removing mileage drill down

This commit is contained in:
2015-10-23 12:13:09 -04:00
parent 25fb070701
commit 7933632cfb
8 changed files with 98 additions and 61 deletions
+44 -7
View File
@@ -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,