Esempio n. 1
0
 private static string GetValue(PropertyInfo property, PersonTableViewModel item)
 {
     return(WebUtility.HtmlEncode(item.GetType()
                                  .GetProperty(property.Name)
                                  .GetValue(item)?.ToString())
            ?? string.Empty);
 }
Esempio n. 2
0
        public static IEnumerable <string> BuildDataTableHeader(PersonTableViewModel tableViewModel)
        {
            var headerString = new List <string>();

            // Get the properties which should appear in the DataTable
            var properties = GetProperties(tableViewModel);

            foreach (var property in properties)
            {
                var listProperties = WebUtility.HtmlEncode(tableViewModel.GetType()
                                                           .GetProperty(property.Name)
                                                           .GetCustomAttributes(false)
                                                           .OfType <ShowOnDataTable>().First().ColumnName
                                                           ?? property.Name);

                // VanityId must *always* be the last property
                //listProperties.Add(item.VanityId.ToString());

                headerString.Add(listProperties);
            }

            return(headerString);
        }
Esempio n. 3
0
        private static IEnumerable <string> PrepareDataTable(IOrderedEnumerable <PropertyInfo> properties, PersonTableViewModel item)
        {
            var listProperties = new List <string>();

            foreach (var property in properties)
            {
                listProperties.Add(GetValue(property, item));
            }

            return(listProperties);
        }
Esempio n. 4
0
 private static IOrderedEnumerable <PropertyInfo> GetProperties(PersonTableViewModel item)
 {
     return(item.GetType().GetProperties()
            .Where(p => Attribute.IsDefined(p, typeof(ShowOnDataTable)))
            .OrderBy(o => o.GetCustomAttributes(false).OfType <ShowOnDataTable>().First().Order));
 }