public async Task <ActionResult> GetKey(short?data) { Helpers.ManageHelper mh = new Helpers.ManageHelper(); string key = ""; try { if (data.HasValue) { key = mh.GetAccessKeyFromSession(this.HttpContext, data.Value); } else { key = mh.GetProviderKeyFromSession(this.HttpContext); } if (key == null || key == "") { return(HttpNotFound("Key not found go to the index page")); } } catch (Exception ex) { Savonia.Web.ErrorReporter.ErrorReporterModule.HandleException(ex, System.Web.HttpContext.Current.Request); return(HttpNotFound("Key not found go to the index page")); } return(Json(key)); }
public async Task <ActionResult> EditAccessKey(AccessKeyModel model) { if (model.KeyId.HasValue) { Helpers.ManageHelper mh = new Helpers.ManageHelper(); model.Key = mh.GetAccessKeyFromSession(this.HttpContext, model.KeyId.Value, false); if (model.Key != null) { ModelState.Remove("key"); ModelState.Add("Key", new ModelState()); ModelState.SetModelValue("Key", new ValueProviderResult(model.Key, model.Key, System.Globalization.CultureInfo.CurrentCulture)); } } if (!ModelState.IsValid) { return(View(model)); } Repository r = new Repository(); try { await r.UpdateAccessKeyAsync(model); } catch (Exception ex) { Savonia.Web.ErrorReporter.ErrorReporterModule.HandleException(ex, System.Web.HttpContext.Current.Request); ModelState.AddModelError("Key", "Unknown error occurred!"); model.Key = "*****"; return(View(model)); } return(RedirectToAction("Details", new { id = model.ProviderID })); }
public async Task <ActionResult> EditAccessKey(int providerID, short?id) { Repository r = new Repository(); Helpers.ManageHelper mh = new Helpers.ManageHelper(); AccessKeyModel model = new AccessKeyModel(); try { var key = mh.GetAccessKeyFromSession(this.HttpContext, id.Value); if (key == null) { return(RedirectToAction("Index")); } model = await r.GetAccessKeyAsync(key); if (model.ProviderID != providerID) { return(RedirectToAction("Details", new { id = providerID })); } } catch (Exception ex) { Savonia.Web.ErrorReporter.ErrorReporterModule.HandleException(ex, System.Web.HttpContext.Current.Request); return(RedirectToAction("Index")); } model.Key = "*****"; model.KeyId = id; return(View(model)); }
public async Task <ActionResult> Details(int id) { Repository r = new Repository(); var model = r.GetProvider(id); Helpers.ManageHelper mh = new Helpers.ManageHelper(); model.Keys = mh.AddAccessKeysToSessionAndUpdate(this.HttpContext, model.Keys); mh.AddProviderKeyToSession(this.HttpContext, model); model.Key = "******"; foreach (var k in model.Keys) { k.Key = "******"; } var sensors = await r.GetSensorsAsync(id); ViewBag.Sensors = sensors; ViewBag.ProviderID = id; return(View(model)); }