/// <summary> /// Gets the bol document as PDF. /// </summary> /// <param name="componentURL">The component URL.</param> public void GetBOLDocumentAsPDF(string componentURL) { if (string.IsNullOrEmpty(componentURL)) { throw new ArgumentNullException("componentURL"); } String[] urlParts = componentURL.ToString().Split('/'); var documentRequestModel = new DocumentRequestModel { CustomerBolNumber = urlParts[2], PdfHeight = float.Parse(urlParts[3]), PdfWidth = float.Parse(urlParts[4]), BolNumber = urlParts[5] }; string bolNumber = string.IsNullOrEmpty(urlParts[5]) ? string.Empty : urlParts[5]; string baseurl = string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Host, ConfigurationManager.AppSettings["AtlasBaseURL"]); baseurl = baseurl + urlParts[0] + "//" + urlParts[1]; byte[] pdfByte = Http.Post <byte[]>(baseurl, documentRequestModel, "application/json", "application/json", cookieContainer: CookieHelper.CookiesContainer); string filename = string.Format("{0}{1}{2}", "BOL - ", string.IsNullOrEmpty(bolNumber) ? Guid.NewGuid().ToString() : bolNumber, ".pdf"); HttpResponse response = System.Web.HttpContext.Current.Response; response.Clear(); response.ClearContent(); response.ClearHeaders(); response.ContentType = "application/pdf"; response.AddHeader("Content-Disposition", "filename=\"" + filename + "\""); response.AddHeader("Content-Length", pdfByte.Length.ToString()); response.AddHeader("Content-Description", "File Transfer"); response.AddHeader("Content-Transfer-Encoding", "binary"); if (!response.Cookies.AllKeys.Contains("fileDownload")) { response.Cookies.Add(new HttpCookie("fileDownload", "true")); } response.BinaryWrite(pdfByte); response.Flush(); }
public async Task <IActionResult> CreateDocument([FromBody] DocumentRequestModel model) { model.Validate(); bool result = await _docManager.AddDocumentType(new DocumentTypeModel { DocumentCode = model.DocumentCode, DocumentName = model.DocumentName, IsRequired = model.IsRequired }); return(Ok(new ResponseModel <object> { RequestSuccessful = true, ResponseCode = ResponseCodes.Successful, Message = "Document has been created successfully.", ResponseData = result })); }
public async Task <IActionResult> UpdateDocument(long Id, [FromBody] DocumentRequestModel model) { model.Validate(); if (Id == default(long)) { throw new BadRequestException("Invalid request. Document is required"); } bool result = await _docManager.UpdateDocumentType(new DocumentTypeModel { DocumentCode = model.DocumentCode, DocumentName = model.DocumentName, IsRequired = model.IsRequired, Id = Id }); return(Ok(new ResponseModel <object> { RequestSuccessful = true, ResponseCode = ResponseCodes.Successful, Message = "Document has been updated successfully.", ResponseData = result })); }