Example #1
0
        public ActionResult GeneralReport(string from, string to)
        {
            try
            {
                string path = Path.Combine(Server.MapPath("~/Reports"), "car.rdlc");
                if (!System.IO.File.Exists(path) || string.IsNullOrEmpty(from) || string.IsNullOrEmpty(to))
                {
                    return View("rptCar");
                }
                tblCar carRpt = new tblCar();
                carRpt.fromDate = Convert.ToDateTime(from);
                carRpt.toDate = Convert.ToDateTime(to);
                List<object> objLst = carRepository.GetCarRpt(carRpt);
                var reportViewModel = carRepository.CarViewModel(objLst, from, to);
                reportViewModel.FileName = path;
                var renderedBytes = reportViewModel.RenderReport();
                if (reportViewModel.ViewAsAttachment)
                {
                    Response.AddHeader("content-disposition", reportViewModel.ReporExportFileName);

                }
                return File(renderedBytes, reportViewModel.LastmimeType);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }