public override IQueryOver <Menu, Menu> CreateQueryForRetrieval(IQueryOver <Menu, Menu> query, string filter, IDictionary <string, object> additionalParameters) { var menuId = InputProcessingMethods.GetValue <string>(additionalParameters, "MenuId"); if (!String.IsNullOrWhiteSpace(menuId)) { query = query.Where(m => m.ParentMenu.Id == menuId); } else { query = query.Where(m => m.ParentMenu == null); } if (!String.IsNullOrWhiteSpace(filter)) { query = query.WhereRestrictionOn(x => x.Name).IsLike(filter, MatchMode.Anywhere); } query = query.OrderBy(m => m.Position).Asc(); return(query); }
public decimal GetDecimalValue(string decimalString, decimal defaultValue = 0) { return(InputProcessingMethods.GetDecimalValue(decimalString, defaultValue)); }
public DateTime?GetDateFromString(string dateString, DateTime?defaultValue = null) { return(InputProcessingMethods.GetDateFromString(dateString, defaultValue)); }
public string GetValue(string propertyName) { return(InputProcessingMethods.GetValue <string>(InputData, propertyName)); }
public T GetDataSourceValue <T>(string propertyName) { return(InputProcessingMethods.GetDataSourceValue <T>(InputData, DataService, propertyName)); }
public T GetValue <T>(string propertyName, T defaultValue = default(T)) { return(InputProcessingMethods.GetValue(InputData, propertyName, defaultValue)); }
public T GetValue <T>(string propertyName, T defaultValue = default(T)) { object value = defaultValue; var item = Data.GetValue(propertyName); var nullableType = Nullable.GetUnderlyingType(typeof(T)); if (item != null) { if (typeof(T).IsEnum || (nullableType != null && nullableType.IsEnum)) { T tempValue; if (InputProcessingMethods.TryParseEnum(item.ToString(), true, out tempValue)) { value = tempValue; } //else if (Nullable.GetUnderlyingType(typeof(T)) != null) else if (nullableType.IsEnum) { value = null; } else { throw new Exception(String.Format("Unable to parse non-nullable enum from value '{0}'", value)); } } else if (typeof(T) == typeof(String)) { value = item.ToString(); } else if (typeof(T) == typeof(bool)) { value = Convert.ToBoolean(item.ToString()); } else if (typeof(T) == typeof(DateTime) || typeof(T) == typeof(DateTime?)) { DateTime date; if (DateTime.TryParse(item.ToString(), out date)) { value = date; } else if (typeof(T) == typeof(DateTime)) { value = new DateTime(1900, 01, 01); ///TODO: What do i do with default dates etc. } } else if (typeof(T) == typeof(int)) { int intValue; if (int.TryParse(item.ToString(), out intValue)) { value = intValue; } else { value = 0; } } else if (typeof(T) == typeof(decimal)) { decimal decimalValue; if (decimal.TryParse(item.ToString(), out decimalValue)) { value = decimalValue; } else { value = 0m; } } else if (typeof(T) == typeof(double)) { double doubleValue; if (double.TryParse(item.ToString(), out doubleValue)) { value = doubleValue; } else { value = 0m; } } else if (typeof(T) == typeof(float)) { float floatValue; if (float.TryParse(item.ToString(), out floatValue)) { value = floatValue; } else { value = 0f; } } else if (typeof(T) == typeof(JObject)) { value = item as JObject; } else if (typeof(T) == typeof(JsonHelper)) { value = Parse(item.ToString()); } else if (typeof(T) == typeof(JsonArray)) { //var arr = item as JArray; //value = new JsonArray(arr.Select(a => FromObject(a)).ToList()); value = JsonArray.FromObject(item); } else { value = item; } } if (value == null) { return(defaultValue); } return((T)value); }