Exemple #1
0
        public ServiceResult <IEnumerable <CopaymentReport> > GetCopaymentReport(CopaymentReportFilter copaymentReportFilter)
        {
            var result = _copaymentReportRepository.GetCopaymentReport(copaymentReportFilter);

            return(new ServiceResult <IEnumerable <CopaymentReport> >
            {
                Success = true,
                Errors = new[] { string.Empty },
                Result = result
            });
        }
        public FileResult Post([FromBody] CopaymentReportFilter copaymentReportFilter)
        {
            var data      = _copaymentReportService.GetCopaymentReport(copaymentReportFilter);
            var rootPath  = Path.Combine(_hostingEnvironment.WebRootPath, "Temp");
            var excelFile = _excelReportService.GenerateExcelReport(rootPath, data.Result);
            var response  = new HttpResponseMessage(HttpStatusCode.OK);
            var bytes     = System.IO.File.ReadAllBytes(excelFile);
            var fileName  = Path.GetFileNameWithoutExtension(excelFile);

            response.Content = new ByteArrayContent(bytes);

            response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
            response.Content.Headers.ContentType                 = new MediaTypeHeaderValue("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
            response.Content.Headers.ContentDisposition.FileName = fileName + ".xlsx";

            return(File(bytes, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", fileName + ".xlsx"));
        }
Exemple #3
0
        public IEnumerable <CopaymentReport> GetCopaymentReport(CopaymentReportFilter copaymentReportFilter)
        {
            var copaymentReport = CopaymentReportQuerys.GetCopaymentReport;

            if (copaymentReportFilter.ProfessionalId > 0)
            {
                copaymentReport += "AND Ags.[ProfessionalId] = @ProfessionalId ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.InitialDateIni))
            {
                copaymentReport += " AND Ags.[InitialDate] >= CONVERT(DATE, @InitialDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.InitialDateEnd))
            {
                copaymentReport += " AND Ags.[InitialDate] <= CONVERT(DATE, @InitialDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.FinalDateIni))
            {
                copaymentReport += " AND Ags.[FinalDate] >= CONVERT(DATE, @FinalDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.FinalDateEnd))
            {
                copaymentReport += " AND Ags.[FinalDate] <= CONVERT(DATE, @FinalDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.FinalDateEnd))
            {
                copaymentReport += " AND Ags.[FinalDate] <= CONVERT(DATE, @FinalDateEnd, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.DeliverDateIni))
            {
                copaymentReport += " AND Ags.[DelieveredCopaymentDate] >= CONVERT(DATE, @DeliverDateIni, 105) ";
            }
            if (!string.IsNullOrEmpty(copaymentReportFilter.DeliverDateEnd))
            {
                copaymentReport += " AND Ags.[DelieveredCopaymentDate] <= CONVERT(DATE, @DeliverDateEnd, 105) ";
            }

            return(_dbConnection.Query <CopaymentReport>(copaymentReport, copaymentReportFilter));
        }