public ActionResult AddDocumentToSigning5() { var model = new AddDocumentToSigning5Model(); model.Document = ExampleDocument; return(View(model)); }
public ActionResult AddDocumentToSigning5(AddDocumentToSigning5Model model) { if (this.ModelState.IsValid) { var tpSigningUri = ConfigurationManager.AppSettings["tpSigning5"]; var certificate = new ClientCertificateProvider().GetClientCertificate(); var document = Encoding.UTF8.GetBytes(model.Document); var urlSuccess = Url.Action("AddDocumentToSigning5Success", "Home", routeValues: null, protocol: Request.Url.Scheme); var urlFailed = Url.Action("AddDocumentToSigning5Failure", "Home", routeValues: null, protocol: Request.Url.Scheme); var additionalInfo = "Some additional info"; // call ePUAP and get their redirect uri // they redirect back to one of your uris var client = new TpSigning5Client(tpSigningUri, certificate); FaultModel fault; var response = client.AddDocumentToSigning(document, urlSuccess, urlFailed, additionalInfo, out fault); if (response != null && !string.IsNullOrEmpty(response.Url) ) { // the returned url has to be stored // it will be used to query the GetSignedDocument this.Session.Add("url", response.Url); return(Redirect(response.Url)); } else { if (fault != null) { this.TempData.Add("Message", string.Format("ePUAP fault: {0}, information: {1}", fault.FaultCode, fault.FaultString)); } else { this.TempData.Add("Message", "Unknown error"); } return(Redirect("/Home/Index")); } } return(View(model)); }