public JsonResult GetBeacons(string fromDate, string toDate, string address, string lat, string lon, string Categories, string radius) { var cats = Categories.Split(',').AsEnumerable<string>(); CategoryManager cm = new CategoryManager(); var allCats = cm.GetAllCategories(); List<Category> categories = new List<Category>(); foreach (var cat in allCats) { if (Categories.Contains(cat.Name.ToLower())) { categories.Add(cat); } } double Long = 0; double Lat = 0; double.TryParse(lat, out Lat); double.TryParse(lon, out Long); DateTime FromDate = DateTime.MinValue; DateTime ToDate = DateTime.MaxValue; DateTime.TryParse(fromDate , out FromDate); DateTime.TryParse(toDate , out ToDate); int Radius = 15; int.TryParse(radius, out Radius); List<Beacon> searchBeacons = null; if (!string.IsNullOrEmpty(address)) { searchBeacons = beaconManager.GetBeacons(address, categories, Radius, FromDate, ToDate); } else { searchBeacons = beaconManager.GetBeacons(Lat, Long, categories, Radius, FromDate, ToDate); } return Json(searchBeacons, JsonRequestBehavior.AllowGet); }
public static IList<Category> GetCategories() { var cat = new CategoryManager(); return cat.GetAllCategories(); }