Exemplo n.º 1
0
        public ActionResult Create(IdentityProvider model, IPCertInputModel cert)
        {
            if (cert != null && cert.Cert != null)
            {
                model.IssuerThumbprint = cert.Cert.Thumbprint;
                if (model.IssuerThumbprint != null)
                {
                    ModelState["IssuerThumbprint"].Errors.Clear();
                    ModelState["IssuerThumbprint"].Value = new ValueProviderResult(model.IssuerThumbprint, model.IssuerThumbprint, ModelState["IssuerThumbprint"].Value.Culture);
                }
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.identityProviderRepository.Add(model);
                    TempData["Message"] = "Identity Provider Created";
                    return(RedirectToAction("IP", new { id = model.ID }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", "Error updating identity provider.");
                }
            }

            // if we're here, then we should clear name so the view thinks it's new
            model.ID = 0;
            return(View("IP", model));
        }
Exemplo n.º 2
0
        public ActionResult Update(IdentityProvider model, IPCertInputModel cert)
        {
            if (cert != null && cert.Cert != null)
            {
                model.IssuerThumbprint = cert.Cert.Thumbprint;
                ModelState["IssuerThumbprint"].Errors.Clear();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.identityProviderRepository.Update(model);
                    TempData["Message"] = "Identity Provider Updated";;
                    return(RedirectToAction("IP", new { id = model.ID }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", "Error updating identity provider.");
                }
            }

            return(View("IP", model));
        }
Exemplo n.º 3
0
        public ActionResult Update(IdentityProvider model, IPCertInputModel cert, string action)
        {
            if (action == "delete")
            {
                this.identityProviderRepository.Delete(model.ID);
                TempData["Message"] = Resources.IPController.IdentityProvidersDeleted;
                return(RedirectToAction("Index"));
            }

            if (cert != null && cert.Cert != null)
            {
                model.IssuerThumbprint = cert.Cert.Thumbprint;
                ModelState["IssuerThumbprint"].Errors.Clear();
            }

            if (ModelState.IsValid)
            {
                try
                {
                    this.identityProviderRepository.Update(model);
                    TempData["Message"] = Resources.IPController.IdentityProviderUpdated;;
                    return(RedirectToAction("IP", new { id = model.ID }));
                }
                catch (ValidationException ex)
                {
                    ModelState.AddModelError("", ex.Message);
                }
                catch
                {
                    ModelState.AddModelError("", Resources.IPController.ErrorUpdatingIdentityProvider);
                }
            }

            return(View("IP", model));
        }