Ejemplo n.º 1
0
        public async Task <HttpResponseMessage> FillableLifePlanPDF(FillableLifePlanPDFRequest fillableLifePlanPDFRequest)
        {
            try
            {
                common = new CommonFunctions();
                httpResponseMessage = new HttpResponseMessage();
                lifePlanPDFResponse = new LifePlanPDFResponse();
                lpdResponse         = new LifePlanDetailTabResponse();
                if (ModelState.IsValid && fillableLifePlanPDFRequest != null)
                {
                    lifePlanPDFResponse = await _LifePlanService.FillableLifePlanPDF(fillableLifePlanPDFRequest);

                    httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, lifePlanPDFResponse);
                    Stream stream = CommonFunctions.GetFilesStream(lifePlanPDFResponse.LifePlanPDF[0].FileName);
                    httpResponseMessage.Content = new StreamContent(stream);
                    httpResponseMessage.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                    httpResponseMessage.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/octet-stream");
                    httpResponseMessage.Content.Headers.ContentDisposition.FileName = "fileNameOfYourChoice";
                }
            }
            catch (Exception Ex)
            {
                lpdResponse.Success     = false;
                lpdResponse.IsException = true;
                lpdResponse.Message     = Ex.Message;
                httpResponseMessage     = Request.CreateResponse(HttpStatusCode.OK, lpdResponse);
                CommonFunctions.LogError(Ex);
            }
            return(httpResponseMessage);
        }
Ejemplo n.º 2
0
        public async Task <HttpResponseMessage> HandleLifePlanVersioning(FillableLifePlanPDFRequest lifePlanDetailRequest)
        {
            try
            {
                httpResponseMessage = new HttpResponseMessage();
                lpdResponse         = new LifePlanDetailTabResponse();
                if (ModelState.IsValid && lifePlanDetailRequest != null)
                {
                    lpdResponse = await _LifePlanService.HandleLifePlanVersioning(lifePlanDetailRequest);

                    httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, lpdResponse);
                }
            }
            catch (Exception Ex)
            {
                lpdResponse.Success     = false;
                lpdResponse.IsException = true;
                lpdResponse.Message     = Ex.Message;
                httpResponseMessage     = Request.CreateResponse(HttpStatusCode.OK, lpdResponse);
                CommonFunctions.LogError(Ex);
            }
            return(httpResponseMessage);
        }