public ActionResult Delete(Beach beach) { Beach dbBeachRow = db.Beaches.Find(beach.ID); db.Beaches.Remove(dbBeachRow); db.SaveChanges(); return RedirectToAction("Index"); }
public ActionResult AddSpotToDB(Beach beach) { if (beach.name != null) { beach.lat = beach.lat.Substring(0, 9); beach.lon = beach.lon.Substring(0, 9); beach.lowWind = 0; beach.maxWind = 0; beach.lowWind48 = 0; beach.maxWind48 = 0; try { using (WebClient wc = new WebClient()) { wc.DownloadString("http://opendata-download-metfcst.smhi.se/api/category/pmp1.5g/version/1/geopoint/lat/" + beach.lat + "/lon/" + beach.lon + "/data.json"); } } catch { TempData["error"] = "Your pin have to be in Sweden only!"; return RedirectToAction("AddSpot"); } db.Beaches.Add(beach); db.SaveChanges(); return RedirectToAction("Index"); } else { return RedirectToAction("AddSpot"); } }