public HttpResponseMessage DownloadProposalFile(string insuranceType, string agentCode, string documentNo, int renewalCount = 0) { DownloadScheuleRequest request = new DownloadScheuleRequest(); request.DocNo = documentNo; request.InsuranceType = insuranceType; request.AgentCode = agentCode; request.RenewalCount = renewalCount; DownloadScheduleResponse result = _scheduleRepo.GetProposalFilePath(request); String FileName = Path.GetFileName(result.FilePath); HttpResponseMessage response = new HttpResponseMessage(); if (System.IO.File.Exists(result.FilePath)) { FileStream stream = File.OpenRead(result.FilePath); response = new HttpResponseMessage(HttpStatusCode.OK); response.Content = new StreamContent(stream); response.Content.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("attachment"); response.Content.Headers.ContentDisposition.FileName = FileName; //response.Content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue(Utility.GetMimeType(FileName));//new System.Net.Http.Headers.MediaTypeHeaderValue("image/png"); return(response); } return(response = new HttpResponseMessage(HttpStatusCode.Gone)); }
/// <summary> /// Get the schedule for specific insurance type (Motor or Home or Travel or Domestic) /// </summary> /// <param name="request">Schedule request.</param> /// <returns>Schedule file path.</returns> public DownloadScheduleResponse GetScheduleFilePath(DownloadScheuleRequest request) { try { string FilePath = string.Empty; if (request.InsuranceType == Constants.Insurance.Travel) { TravelInsurance travel = new TravelInsurance(); TravelSavedQuotationResponse travelresult = travel.GetSavedQuotationByPolicy(request.DocNo, "portal", request.AgentCode, request.IsEndorsement, request.EndorsementID); FilePath = this.CreateTravelSchudles(travelresult, false); } else if (request.InsuranceType == Constants.Insurance.Motor) { MotorInsurance motor = new MotorInsurance(); MotorSavedQuotationResponse motorresult = motor.GetSavedMotorPolicy(request.DocNo, "", request.AgentCode, request.IsEndorsement, request.EndorsementID, request.RenewalCount); FilePath = this.CreateMotorSchudles(motorresult.MotorPolicyDetails, false); } else if (request.InsuranceType == Constants.Insurance.DomesticHelp) { DomesticHelp domestic = new DomesticHelp(); DomesticHelpSavedQuotationResponse domesticresult = domestic.GetSavedDomesticPolicy(request.DocNo, request.AgentCode, request.IsEndorsement, request.EndorsementID); FilePath = this.CreateDomesticSchudles(domesticresult, false); } else { HomeInsurance home = new HomeInsurance(); HomeSavedQuotationResponse homeresult = home.GetSavedQuotationPolicy(request.DocNo, "", request.AgentCode, request.IsEndorsement, request.EndorsementID, request.RenewalCount); FilePath = CreateHomeSchudles(homeresult, false); } return(new DownloadScheduleResponse { FilePath = FilePath, IsTransactionDone = true }); } catch (Exception ex) { return(new DownloadScheduleResponse { IsTransactionDone = false, TransactionErrorMessage = ex.Message }); } }
/// <summary> /// Get motor proposal file. /// </summary> /// <param name="request">Schedule request.</param> /// <returns>Schedule file path.</returns> public DownloadScheduleResponse GetProposalFilePath(DownloadScheuleRequest request) { try { string FilePath = string.Empty; if (request.InsuranceType == Constants.Insurance.Motor) { MotorInsurance motor = new MotorInsurance(); MotorSavedQuotationResponse motorresult = motor.GetSavedMotorPolicy(request.DocNo, "", request.AgentCode, false, 0, request.RenewalCount); FilePath = this.CreateMotorProposal(motorresult.MotorPolicyDetails, false); } return(new DownloadScheduleResponse { FilePath = FilePath, IsTransactionDone = true }); } catch (Exception ex) { return(new DownloadScheduleResponse { IsTransactionDone = false, TransactionErrorMessage = ex.Message }); } }