public ActionResult ReaderKey(string id, ReaderKey model) { try { var cs = reader.GetConfigSet(id); if (!cs.UserHasAccessTo()) { throw new UnauthorizedAccessException("Access denied to configset"); } ViewBag.Trail = cs.GetTrail(); ViewBag.Id = cs.Id; ViewBag.System = cs.System; ViewBag.Name = cs.Name; cs.AllowAccessWithRootKey = model.AllowMaster; cs.AllowAccessWithUserTokens = model.AllowUserTokens; if (model.GenerateNew) { reader.GenerateReaderKey(cs); } reader.UpdateConfigSet(cs); return(RedirectToAction("ReaderKey", new { id = id })); } catch (Exception exception) { exception.Log(); throw exception; } }