public ActionResult Create() { var model = new SensorSearch(); var locations = DocumentDBRepository<Sensor>.GetItems().Select(t => t.AtLocation).AsEnumerable().Distinct(); var types = DocumentDBRepository<Sensor>.GetItems().Select(t => t.Type).AsEnumerable().Distinct(); ViewBag.SensorDataLocation = new SelectList(locations); ViewBag.SensorDataType = new SelectList(types); return View("Create"); }
// GET: Sensor public ActionResult Index() { var model = new SensorSearch(); var locations = DocumentDBRepository<Sensor>.GetItems().Select(t => t.AtLocation).AsEnumerable().Distinct(); var types = DocumentDBRepository<Sensor>.GetItems().Select(t => t.Type).AsEnumerable().Distinct(); foreach (var location in locations) { model.Locations.Add(new SelectListItem { Text = location, Value = location }); } foreach (var type in types) { model.Types.Add(new SelectListItem { Text = type, Value = type }); } return View(model); }
public PartialViewResult IndexPartial(SensorSearch model) { var items = DocumentDBRepository<Sensor>.GetItems(); if (model != null) { if (model.AtLocation != null) { items = items.Where(x => x.AtLocation == model.AtLocation); } if (model.Type != null) { items = items.Where(y => y.Type == model.Type); } } var itemList = items.ToList(); foreach (Sensor sensor in itemList) { //simple fix because of datatime inconsistency if(sensor.Timestamp.Length<15) sensor.Timestamp = (ConvertFromUnixTimestamp(System.Convert.ToDouble(sensor.Timestamp)).ToString()); } return PartialView("_IndexPartial", itemList); }