public ActionResult Protocol(string id)
 {
     var vm = new ProtocolsViewModel(this.ConfigurationRepository);
     var protocol = vm.GetProtocol(id);
     if (protocol == null) return HttpNotFound();
     return View("Protocol", protocol);
 }
 public ActionResult Menu()
 {
     var pvm = new ProtocolsViewModel(ConfigurationRepository);
     var list = pvm.Protocols.Where(x => x.Enabled).ToArray();
     if (list.Length > 0)
     {
         var vm = new ChildMenuViewModel();
         vm.Items = list.Select(x =>
             new ChildMenuItem
             {
                 Controller = "Protocol",
                 Action = "Protocol",
                 Title = x.Name,
                 RouteValues = new { id = x.NameWithoutSpaces }
             }).ToArray();
         return PartialView("ChildMenu", vm);
     }
     return new EmptyResult();
 }
        public ActionResult Index(ProtocolsInputModel model)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    model.Update(this.ConfigurationRepository);
                    TempData["Message"] = Resources.ProtocolController.UpdateSuccessful;
                    return RedirectToAction("Index");
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.ProtocolController.ErrorUpdatingProtocols);
                }
            }

            var vm = new ProtocolsViewModel(ConfigurationRepository);
            return View("Index", vm);
        }
 public ActionResult UpdateProtocol(string id)
 {
     var vm = new ProtocolsViewModel(this.ConfigurationRepository);
     var protocol = vm.GetProtocol(id);
     if (this.TryUpdateModel(protocol.Protocol, "protocol"))
     {
         try
         {
             vm.UpdateProtocol(protocol);
             TempData["Message"] = Resources.ProtocolController.UpdateSuccessful;
             return RedirectToAction("Protocol", new { id });
         }
         catch (ValidationException ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
         catch
         {
             ModelState.AddModelError("", Resources.ProtocolController.ErrorUpdatingProtocol);
         }
     }
     return View("Protocol", protocol);
 }
 public ActionResult Index()
 {
     var vm = new ProtocolsViewModel(ConfigurationRepository);
     return View("Index", vm);
 }
        public ActionResult UpdateADFSIntegration(
            [Bind(Exclude = "EncryptionCertificate")] AdfsIntegrationConfiguration protocol,
            [Bind(Prefix = "protocol")] AdfsIntegrationCertInputModel cert,
            bool? removeCert)
        {
            string id = "ADFSIntegration";

            if (removeCert == true)
            {
                protocol.EncryptionCertificate = null;
            }
            else if (cert.EncryptionCertificate != null)
            {
                protocol.EncryptionCertificate = cert.Cert;
            }
            else
            {
                protocol.EncryptionCertificate = this.ConfigurationRepository.AdfsIntegration.EncryptionCertificate;
            }

            if (protocol.Enabled)
            {
                if (protocol.SamlAuthenticationEnabled && protocol.EncryptionCertificate == null)
                {
                    ModelState.AddModelError("protocol.EncryptionCertificate", "EncryptionCertificate required when SamlAuthenticationEnabled is enabled.");
                }
                if (protocol.JwtAuthenticationEnabled && protocol.EncryptionCertificate == null)
                {
                    ModelState.AddModelError("protocol.EncryptionCertificate", "EncryptionCertificate required when JwtAuthenticationEnabled is enabled.");
                }
            } 
            
            if (ModelState.IsValid)
            {
                try
                {
                    this.ConfigurationRepository.AdfsIntegration = protocol;
                    TempData["Message"] = "Update Successful";
                    return RedirectToAction("Protocol", new { id });
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", "Error updating protocol.");
                }
            }

            var vm = new ProtocolsViewModel(this.ConfigurationRepository);
            var orig = vm.GetProtocol(id);
            return View("ADFSIntegration", orig);
        }