Esempio n. 1
0
        public IActionResult GenerateReport([Bind("ReportType")] ShareReportViewModel report)
        {
            var fileName = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            var url      = "";
            var result   = false;

            switch (report.ReportType)
            {
            case ShareReportType.SharePriceReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"DaftarHargaSaham_{fileName}");
                var shareList = _shareService.GetSharePricePage().ToList();
                result = ExportToExcel.Download <SharePriceModel>(_hostingEnvironment.WebRootPath, shareList, $"DaftarHargaSaham_{fileName}");
                break;

            case ShareReportType.ShareholderReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPemegangSaham_{fileName}");
                var shareholderReport = _shareTransactionService.GenerateShareholderReport();
                result = ExportToExcel.Download <ShareholderReportViewModel>(_hostingEnvironment.WebRootPath, shareholderReport, $"LaporanPemegangSaham_{fileName}");
                break;
            }

            ViewBag.Report   = "Download laporan";
            ViewBag.Download = url;
            return(View("Report"));
        }
Esempio n. 2
0
        public IActionResult GenerateReport([Bind("ReportType")] ReportViewModel report)
        {
            var    fileName = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            string url      = "";
            bool   result   = false;

            switch (report.ReportType)
            {
            case LoanReportType.LoanReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPinjamanUang_{fileName}");
                var loanReport = _loanService.GenerateLoanReport();
                result = ExportToExcel.Download <LoanReportViewModel>(_hostingEnvironment.WebRootPath, loanReport, $"LaporanPinjamanUang_{fileName}");
                break;

            case LoanReportType.LoanRepaymentReport:
                url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"LaporanPengembalianPinjamanUang_{fileName}");
                var loanRepaymentReport = _loanRepaymentService.GenerateLoanRepaymentReport();
                result = ExportToExcel.Download <LoanRepaymentReportViewModel>(_hostingEnvironment.WebRootPath, loanRepaymentReport, $"LaporanPengembalianPinjamanUang_{fileName}");
                break;
            }

            ViewBag.Report   = "Download laporan";
            ViewBag.Download = url;
            return(View("Report"));
        }
Esempio n. 3
0
        public IActionResult Export(List <SharePriceModel> shareList)
        {
            var fileName = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";

            // Download location from the browser
            string url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"DaftarHargaSaham{fileName}");

            var result = ExportToExcel.Download <SharePriceModel>(_hostingEnvironment.WebRootPath, shareList, $"DaftarHargaSaham{fileName}");

            TempData["DownLoad"] = url;

            return(RedirectToAction(nameof(List)));
        }
Esempio n. 4
0
        public IActionResult GenerateReport()
        {
            var fileName   = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            var memberList = _memberService.GetMemberPage().ToList();

            // Download location from the browser
            string url = string.Format("{0}://{1}/{2}", Request.Scheme, Request.Host, $"DaftarAnggota_{fileName}");

            var result = ExportToExcel.Download <MemberModel>(_hostingEnvironment.WebRootPath, memberList, $"DaftarAnggota_{fileName}");

            ViewBag.Report   = "Download laporan";
            ViewBag.Download = url;
            return(View("Report"));
        }
Esempio n. 5
0
        public IActionResult Export()
        {
            var fileName    = $"{DateTime.Now.Day.ToString()}_{DateTime.Now.Month.ToString()}_{DateTime.Now.Year.ToString()}.xlsx";
            var contactList = _contactRepository.GetAll().ToList();

            byte[] fileContent;

            var fileLocation = Path.Combine(_environment.WebRootPath, $"MyContacts_{fileName}");

            // Download location from the browser
            var result = ExportToExcel.Download <Contact>(fileLocation, contactList);
            var path   = _environment.WebRootPath + $"\\MyContacts_{fileName}";

            using (BinaryReader br = new BinaryReader(System.IO.File.Open(path, FileMode.Open)))

            {
                fileContent = new byte[br.BaseStream.Length];
                fileContent = br.ReadBytes((int)br.BaseStream.Length);
            }

            System.IO.File.Delete(fileLocation);
            return(Ok(fileContent));
        }