public async Task <HttpResponseMessage> DownloadUPloadedFile(IncidentManagementRequest incidentManagementRequest) { try { common = new CommonFunctions(); httpResponseMessage = new HttpResponseMessage(); allPDFUploadResponse = new AllPDFUploadResponse(); if (ModelState.IsValid && incidentManagementRequest != null) { allPDFUploadResponse = await _IIncidentManagementService.DownloadUPloadedFile(incidentManagementRequest); httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, allPDFUploadResponse); Stream stream = CommonFunctions.GetFilesStream(allPDFUploadResponse.UploadedPDFResponse[0].PDFDocument); httpResponseMessage.Content = new StreamContent(stream); httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = "test.pdf" }; httpResponseMessage.Content.Headers.Add("Access-Control-Expose-Headers", "Content-Disposition"); httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); httpResponseMessage.Content.Headers.ContentDisposition.FileName = "fileNameOfYourChoice.pdf"; } } catch (Exception Ex) { incidentManagementGeneralRespnse.Success = false; incidentManagementGeneralRespnse.IsException = true; incidentManagementGeneralRespnse.Message = Ex.Message; CommonFunctions.LogError(Ex); httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, incidentManagementGeneralRespnse); } return(httpResponseMessage); }
public async Task <HttpResponseMessage> DeleteMasterRecord(IncidentManagementRequest incidentManagementRequest) { try { httpResponseMessage = new HttpResponseMessage(); incidentManagementGeneralRespnse = new IncidentManagementGeneralRespnse(); if (ModelState.IsValid && incidentManagementRequest != null) { incidentManagementGeneralRespnse = await _IIncidentManagementService.DeleteMasterRecord(incidentManagementRequest); httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, incidentManagementGeneralRespnse); } } catch (Exception Ex) { incidentManagementGeneralRespnse.Success = false; incidentManagementGeneralRespnse.IsException = true; incidentManagementGeneralRespnse.Message = Ex.Message; httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, incidentManagementGeneralRespnse); CommonFunctions.LogError(Ex); } return(httpResponseMessage); }