示例#1
0
        // [AuthorizeUser]
        public async Task <HttpResponseMessage> GenerateAndImportXML(XMLImportRequest xmlImportRequest)
        {
            try
            {
                httpResponseMessage = new HttpResponseMessage();
                cansResponse        = new CANSResponse();
                if (ModelState.IsValid && xmlImportRequest != null)
                {
                    cansResponse = await _ICANSService.GenerateAndImportXML(xmlImportRequest);

                    httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, cansResponse);
                    if (!File.Exists(cansResponse.CommonCANSRsponse[0].FileName))
                    {
                        httpResponseMessage.StatusCode   = HttpStatusCode.NotFound;
                        httpResponseMessage.ReasonPhrase = string.Format("File not found: {0} .", "file");
                        throw new HttpResponseException(httpResponseMessage);
                    }
                    Stream stream = CommonFunctions.GetFilesStream(cansResponse.CommonCANSRsponse[0].FileName);

                    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)
            {
                cansResponse.Success     = false;
                cansResponse.IsException = true;
                cansResponse.Message     = Ex.Message;
                httpResponseMessage      = Request.CreateResponse(HttpStatusCode.OK, cansResponse);
                CommonFunctions.LogError(Ex);
            }
            return(httpResponseMessage);
        }
示例#2
0
        public async Task <HttpResponseMessage> GetCANSAssessmentDetails(CANSRequest cansRequest)
        {
            try
            {
                httpResponseMessage = new HttpResponseMessage();
                cansResponse        = new CANSResponse();
                if (ModelState.IsValid && cansRequest != null)
                {
                    cansResponse = await _ICANSService.GetCANSAssessmentDetails(cansRequest);

                    httpResponseMessage = Request.CreateResponse(HttpStatusCode.OK, cansResponse);
                }
            }
            catch (Exception Ex)
            {
                cansResponse.Success     = false;
                cansResponse.IsException = true;
                cansResponse.Message     = Ex.Message;
                httpResponseMessage      = Request.CreateResponse(HttpStatusCode.OK, cansResponse);
                CommonFunctions.LogError(Ex);
            }
            return(httpResponseMessage);
        }
示例#3
0
        public async Task <HttpResponseMessage> AddCansTreatmentPlanFields(TreatmentPlanRequest treatmentPlanRequest)
        {
            try
            {
                httpResponseMessage = new HttpResponseMessage();
                cansResponse        = new CANSResponse();

                if (ModelState.IsValid && treatmentPlanRequest != null)
                {
                    cansResponse = await _ICANSService.AddCansTreatmentPlanFields(treatmentPlanRequest);

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