public HttpResponseMessage DownloadUnsucessfulShipments(FrayteCommercialInvoiceFileName FileName) { try { if (FileName != null && !string.IsNullOrEmpty(FileName.FileName)) { return(UnsucessfulShipments(FileName.FileName)); } else { return(null); } } catch (Exception ex) { return(null); } }
public HttpResponseMessage DownloadrateRateCardExcelTemplate(FrayteCommercialInvoiceFileName FileName) { try { if (FileName != null && !string.IsNullOrEmpty(FileName.FileName)) { return(DownloadRateCardTemplate(FileName.FileName)); } else { return(null); } } catch (Exception ex) { return(null); } }
public HttpResponseMessage DownloadAWBImage(FrayteCommercialInvoiceFileName file) { string filePath = HttpContext.Current.Server.MapPath("~/AwbImage/" + file.FileName); using (MemoryStream ms = new MemoryStream()) { using (FileStream filestrm = new FileStream(filePath, FileMode.Open, FileAccess.Read)) { byte[] bytes = new byte[filestrm.Length]; filestrm.Read(bytes, 0, (int)filestrm.Length); ms.Write(bytes, 0, (int)filestrm.Length); HttpResponseMessage httpResponseMessage = new HttpResponseMessage(); httpResponseMessage.Content = new ByteArrayContent(bytes); httpResponseMessage.Content.Headers.Add("download-status", "downloaded"); httpResponseMessage.Content.Headers.Add("x-filename", file.FileName); httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment"); httpResponseMessage.Content.Headers.ContentDisposition.FileName = file.FileName; httpResponseMessage.StatusCode = HttpStatusCode.OK; return(httpResponseMessage); } } }