public ActionResult DownloadAllFacility([Bind(Include = "Region")] Facility facility)
        {
            if (string.IsNullOrEmpty(facility.Region))
            {
                ModelState.AddModelError("", "Please Select Region.");
                return(View(facility));
            }
            FacilityReport  facilityReport = new FacilityReport();
            ApplicationUnit unit           = new ApplicationUnit();

            List <Model.Facility> dbFacilities = unit.Facilities.GetAll()
                                                 .Include(b => b.Buildings)
                                                 .Include(d => d.DeedsInfo)
                                                 .Include(p => p.ResposiblePerson)
                                                 .Include("Location.GPSCoordinates")
                                                 .Include("Location.BoundryPolygon")
                                                 .Where(ss => ss.Status == "Submitted" && ss.Location.Region.Trim().ToLower() == facility.Region.Trim().ToLower())
                                                 .ToList();

            if (dbFacilities.Count() == 0)
            {
                ModelState.AddModelError("", "No Facilities Found For Selected Region.");
                return(null);
            }
            else
            {
                using (var memoryStream = new MemoryStream())
                {
                    using (ZipArchive ziparchive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true))
                    {
                        foreach (var item in dbFacilities)
                        {
                            Model.OriginalData dbOriginalData = unit.OriginalDatas.GetAll().Where(o => o.VENUS_CODE.Trim().ToLower() == item.ClientCode.Trim().ToLower()).FirstOrDefault();
                            string             filePath       = facilityReport.GenerateFacilityReport(item, dbOriginalData);
                            ziparchive.CreateEntryFromFile(filePath, item.ClientCode + ".pdf");
                        }
                    }
                    DeleteAllFile();
                    return(File(memoryStream.ToArray(), "application/zip", "facilities.zip"));
                }
            }
        }
        // GET: Facility/Edit/5
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult DownloadFacility(string clientCode)
        {
            FacilityReport  facilityReport = new FacilityReport();
            ApplicationUnit unit           = new ApplicationUnit();

            Model.Facility dbFacility = unit.Facilities.GetAll()
                                        .Include(b => b.Buildings)
                                        .Include(d => d.DeedsInfo)
                                        .Include(c => c.Portfolio)
                                        .Include(p => p.ResposiblePerson)
                                        .Include("Location.GPSCoordinates")
                                        .Include("Location.BoundryPolygon")
                                        .Where(f => f.ClientCode.ToLower() == clientCode.ToLower()).FirstOrDefault();
            if (dbFacility == null)
            {
                return(RedirectToAction("Index"));
            }

            Model.OriginalData dbOriginalData = unit.OriginalDatas.GetAll()
                                                .Where(o => o.VENUS_CODE.Trim().ToLower()
                                                       == dbFacility.ClientCode.Trim().ToLower())
                                                .FirstOrDefault();

            string filePath = facilityReport.GenerateFacilityReport(dbFacility, dbOriginalData);

            using (var webClient = new WebClient())
            {
                if (!System.IO.File.Exists(filePath))
                {
                    return(null);
                }
                byte[] file = webClient.DownloadData(filePath);
                DeleteAllFile();
                return(File(file, MediaTypeNames.Application.Pdf));
            }
        }