public async Task <IActionResult> Create( [FromQuery] string templateId, [FromQuery] string templateVersion, [FromQuery] string key) { DocumentCreate create = null; if (!string.IsNullOrEmpty(key)) { create = _documentEncoder.Decode(key); } else if (!string.IsNullOrEmpty(templateId) && !string.IsNullOrEmpty(templateVersion)) { create = GetDocumentCreate(templateId, templateVersion); } else { return(BadRequest()); } if (Request.ContentType == "text/plain") { var document = await _documentService.CreateTextDocumentAsync(create); return(Content(document.Body)); } else if (Request.ContentType == "application/vnd+document+key") { var document = _documentEncoder.Encode(create); return(Content(document)); } else if (Request.ContentType == "application/vnd+document+html") { var document = await _documentService.CreateHtmlDocumentAsync(create); return(Ok(document)); } else if (Request.ContentType == "application/vnd+document+json") { var document = await _documentService.CreateSerializableDocumentAsync(create); return(Ok(document)); } else { var document = await _documentService.CreateHtmlDocumentAsync(create); var html = @" <html> <head> <style type=""text/css"">" + document.Css + @"</style> </head> <body>" + string.Join(string.Empty, document.Pages) + @"</body> </html>"; Response.ContentType = "text/html; charset=utf-8"; return(Content(html)); } }
public bool CreateDocument(DocumentCreate model, string pathString, string fileName) { string docString = "/Content/docs/"; string fullFileName = fileName; if (fileName.Length > 15) { fileName = fileName.Substring(0, 10) + "..." + fileName.Substring(fileName.Length - 4, 4); } var entity = new Document() { OwnerId = _userId, DocName = fileName, DocString = docString + fullFileName, DocType = model.DocType, DateCreated = DateTimeOffset.Now, LocationId = model.LocationId }; using (var ctx = new ApplicationDbContext()) { ctx.Documents.Add(entity); return(ctx.SaveChanges() == 1); } }
public async Task <ActionResult <Document> > CreateBigDocumentForCustomer(int customerId, CancellationToken cancellationToken) { DocumentCreate document = new DocumentCreate() { ContentType = Request.ContentType, }; using (document.Datastream = new MemoryStream()) { await Request.StreamFile(document.Datastream); Document result = await documentFacade.UploadDocument(customerId, document, cancellationToken); return(Ok(result)); } }
private async Task <DocumentResponse <DocumentCreated> > _CreateDocument(DocumentDataCreate _docData) { DocumentCreate doc = new DocumentCreate(); doc.data.Add(_docData); string bodyRequest = doc.toJson(); IRestResponse createDocumentResponse = await PostAsync(GetBaseResource(), null, null, bodyRequest); if (createDocumentResponse.StatusCode != System.Net.HttpStatusCode.OK) { //handle according to established exception policy throw (new CreateDocumentException(createDocumentResponse)); } return(JsonConvert.DeserializeObject <DocumentResponse <DocumentCreated> >(createDocumentResponse.Content)); }
public async Task <Document> UploadDocument(int customerId, DocumentCreate createRequest, CancellationToken cancellationToken) { bool existsCustomer = await uow.Set <Customer>().AnyAsync(x => x.Id == customerId, cancellationToken); if (!existsCustomer) { throw new ObjectNotFoundException("Customer nebyl nalezen!"); } string containerName = ContainerPaths.CustomerDocuments(customerId); DocumentDbo document = mapper.Map <DocumentDbo>(createRequest, x => x.Items.Add("customerId", customerId)); await azureStorageService.UploadAsync(createRequest.Datastream, containerName, document.Id.ToString(), cancellationToken); uow.Add(document); await uow.SaveChangesAsync(cancellationToken); return(mapper.Map <Document>(document)); }
public ActionResult Create(DocumentCreate model, HttpPostedFileBase file) { if (ModelState.IsValid) { var service = new DocumentService(Guid.Parse(User.Identity.GetUserId())); string path = ""; string fileName = ""; if (file != null) { fileName = Path.GetFileName(file.FileName); path = Path.Combine(Server.MapPath("~/Content/docs"), fileName); file.SaveAs(path); } service.CreateDocument(model, path, fileName); return(RedirectToAction("Index")); } return(View(model)); }
public async Task <SigningRequestResult> CreateSigningRequestAsync(DocumentCreate document) { // TODO: Validate document var template = await _templateRepository.GetTemplateAsync(document.TemplateId); var signingRequest = new SigningRequest() { Id = Guid.NewGuid().ToString(), TemplateId = template.Id, TemplateVersion = template.Version, InputValues = document.InputValues, Signatories = _documentExportsFactory .Create(template, document.InputValues) .ListSignatories() .Select(s => s.Id) }; await _signingRequestRepository.CreateSigningRequestAsync(signingRequest); var signingKeysDecodedByEmail = signingRequest.Signatories.ToDictionary( email => email, email => new SigningKey() { SignatoryEmail = email, SigningRequestId = signingRequest.Id }); var signingUrlsByEmail = signingKeysDecodedByEmail.ToDictionary( kvp => kvp.Key, kvp => $"{_hostOptions.Signing}/{_signingKeyEncoder.Encode(kvp.Value)}?v=1"); await _signingNotifier.NotifyAsync(signingUrlsByEmail); return(new SigningRequestResult() { Type = _signingNotifier.NotificationTypeId, TypeData = signingUrlsByEmail }); }
private static async Task CreateSigningRequestAsync(IServiceProvider serviceProvider) { var signingService = serviceProvider.GetRequiredService <SigningService>(); var document = new DocumentCreate() { TemplateId = "non-disclosure-agreement", TemplateVersion = 1, InputValues = new Dictionary <string, dynamic>() { { "organisation.name", "Automio Limited" }, { "organisation.location", "New Plymouth" }, { "organisation.description", "operates a carpet manufacturing factory in Stratford" }, { "contractor.type", "company" }, { "contractor.company.name", "Lava Lamps Limited" }, { "contractor.company.location", "New Plymouth" }, { "disclosure_reason", "To provide marketing services to the Organisation" }, { "disclosure_access", true }, { "disclosure_access.details.persons", "sub-contractors, board members" }, { "document_signed", true }, { "organisation.representative.name", "Liz Gilchrist" }, { "organisation.representative.email", "*****@*****.**" }, { "contractor.company.representative.name", "Michael Fry" }, { "contractor.company.representative.email", "*****@*****.**" } } }; var result = await signingService.CreateSigningRequestAsync(document); var signingUrlByEmail = result.TypeData as Dictionary <string, string>; signingUrlByEmail.ForEach(kvp => { Console.WriteLine(kvp.Value); Console.WriteLine(); }); }
public async Task <NodeEntry> CreateNode(DocumentCreate parameters) { return(await _documentService.Create(SpisumNames.NodeTypes.Document, SpisumNames.Paths.MailRoomUnfinished, parameters.DocumentType, parameters.NodeId)); }
public async Task <iBanFirstApiResponse <Document> > Upload(DocumentObject documentObject, DocumentType documentType, DocumentCreate document) { return(await _client.MakeApiRequest <Document>($"documents/upload/{Enum.GetName(typeof(DocumentObject), documentObject)}/{Enum.GetName(typeof(DocumentType), documentType)}/", Utilities.RequestMethod.POST, document)); }