Exemplo n.º 1
0
        public async Task <IActionResult> AddSite(ResearchSite site)
        {
            var     address = site.SiteStreetAddress + ", " + site.SiteCity + ", " + site.SiteState;
            GeoCode geocode = await _apiCalls.GoogleGeocoding(address);

            site.Latitude  = geocode.results[0].geometry.location.lat;
            site.Longitude = geocode.results[0].geometry.location.lng;

            _context.ResearchSite.Add(site);
            _context.SaveChanges();

            return(RedirectToAction("Index"));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> EditSite(ResearchSite site)
        {
            var     researchSite = _context.ResearchSite.Where(r => r.SiteId == site.SiteId).SingleOrDefault();
            var     address      = site.SiteStreetAddress + ", " + site.SiteCity + ", " + site.SiteState;
            GeoCode geocode      = await _apiCalls.GoogleGeocoding(address);

            researchSite.Latitude          = geocode.results[0].geometry.location.lat;
            researchSite.Longitude         = geocode.results[0].geometry.location.lng;
            researchSite.SiteCity          = site.SiteCity;
            researchSite.SiteName          = site.SiteName;
            researchSite.SiteState         = site.SiteState;
            researchSite.SiteZip           = site.SiteZip;
            researchSite.SiteStreetAddress = site.SiteStreetAddress;
            _context.SaveChanges();
            return(RedirectToAction("AllSites"));
        }
Exemplo n.º 3
0
        public ActionResult ExportEnvironment(ResearchSite research)
        {
            var sites = _context.Environmental.Where(e => e.SiteName == research.SiteName).ToList();

            using (var workbook = new XLWorkbook())
            {
                var worksheet  = workbook.Worksheets.Add("SiteInformation");
                var currentRow = 1;
                worksheet.Cell(currentRow, 1).Value = "Research Date";
                worksheet.Cell(currentRow, 2).Value = "Opening Temperature";
                worksheet.Cell(currentRow, 3).Value = "Closing Temperature";
                worksheet.Cell(currentRow, 4).Value = "Cloud Cover";
                worksheet.Cell(currentRow, 5).Value = "Precipitation";
                worksheet.Cell(currentRow, 6).Value = "Open Time";
                worksheet.Cell(currentRow, 7).Value = "Close Time";
                worksheet.Cell(currentRow, 8).Value = "Site Name";

                foreach (var site in sites)
                {
                    currentRow++;
                    worksheet.Cell(currentRow, 1).Value = site.ResearchDate;
                    worksheet.Cell(currentRow, 2).Value = site.OpenTemp;
                    worksheet.Cell(currentRow, 3).Value = site.CloseTemp;
                    worksheet.Cell(currentRow, 4).Value = site.CloudCover;
                    worksheet.Cell(currentRow, 5).Value = site.Precipitation;
                    worksheet.Cell(currentRow, 6).Value = site.OpenTime;
                    worksheet.Cell(currentRow, 7).Value = site.CloseTime;
                    worksheet.Cell(currentRow, 8).Value = site.SiteName;
                }

                using (var stream = new MemoryStream())
                {
                    workbook.SaveAs(stream);
                    var content = stream.ToArray();

                    return(File(
                               content, "application/vnd.openxmlformats-officedocument.spreadsheet.sheet", "SiteInformation.xlsx"));
                }
            }
        }
Exemplo n.º 4
0
        public ActionResult ViewDailySiteData(ResearchSite research)
        {
            var siteData = _context.Environmental.Where(e => e.SiteName == research.SiteName).ToList();

            return(View("DisplayData", siteData));
        }