public List<BookInfo> GetBookDetails (int count) { List<BookInfo> bookDetails = new List<BookInfo> (); for (int i = 1; i <= count; i++) { var ord = new BookInfo () { CustomerID = i, BookID = BookID [random.Next (8)], BookName = BookNames [random.Next (5)], Country = Country [random.Next (8)], Price = random.Next (30, 200), FirstName = FirstNames [random.Next (7)], LastName = LastNames [random.Next (9)], }; bookDetails.Add (ord); } return bookDetails; }
private bool MakeStringFilter (BookInfo o, string option, string condition) { var value = o.GetType ().GetProperty (option); var exactValue = value.GetValue (o, null); exactValue = exactValue.ToString ().ToLower (); string text = FilterText.ToLower (); var methods = typeof(string).GetMethods (); if (methods.Count () != 0) { if (condition == "Contains") { var methodInfo = methods.FirstOrDefault (method => method.Name == condition); bool result1 = (bool)methodInfo.Invoke (exactValue, new object[] { text }); return result1; } else if (exactValue.ToString () == text.ToString ()) { bool result1 = String.Equals (exactValue.ToString (), text.ToString ()); if (condition == "Equals") return result1; else if (condition == "NotEquals") return false; } else if (condition == "NotEquals") { return true; } return false; } else return false; }
private bool MakeNumericFilter (BookInfo o, string option, string condition) { var value = o.GetType ().GetProperty (option); var exactValue = value.GetValue (o, null); double res; bool checkNumeric = double.TryParse (exactValue.ToString (), out res); if (checkNumeric) { switch (condition) { case "Equals": try { if (exactValue.ToString () == FilterText) { if (Convert.ToDouble (exactValue) == (Convert.ToDouble (FilterText))) return true; } } catch (Exception e) { Debug.WriteLine (e.Message); } break; case "NotEquals": try { if (Convert.ToDouble (FilterText) != Convert.ToDouble (exactValue)) return true; } catch (Exception e) { Debug.WriteLine(e.Message); return true; } break; } } return false; }
private bool MakeNumericFilter (BookInfo o, string option, string condition) { var value = o.GetType ().GetProperty (option); var exactValue = value.GetValue (o, null); double res; bool checkNumeric = double.TryParse (exactValue.ToString (), out res); if (checkNumeric) { switch (condition) { case "Equals": try { if (exactValue.ToString () == FilterText) { if (Convert.ToDouble (exactValue) == (Convert.ToDouble (FilterText))) return true; } } catch (Exception e) { Console.WriteLine (e); Toast.MakeText (this.context, "Invalid input", ToastLength.Short).Show (); } break; case "NotEquals": try { if (Convert.ToDouble (FilterText) != Convert.ToDouble (exactValue)) return true; } catch (Exception e) { Console.WriteLine (e); Toast.MakeText (this.context, "Invalid input", ToastLength.Short).Show (); return true; } break; } } return false; }