Ejemplo n.º 1
0
        // GET:
        public IActionResult AddSpot()
        {
            ViewBag.Title = "Add A New Spot";
            AddSpotViewModel addSpotViewModel = new AddSpotViewModel();

            return(View(addSpotViewModel));
        }
Ejemplo n.º 2
0
 public IActionResult AddSpot(AddSpotViewModel addSpotViewModel)
 {
     ViewBag.Title = "Add A New Spot";
     if (ModelState.IsValid)
     {
         // Add New Location to the database
         Marker newMarker = new Marker
         {
             Name     = addSpotViewModel.Name,
             Address  = addSpotViewModel.Address,
             Lat      = addSpotViewModel.Lat,
             Lng      = addSpotViewModel.Lng,
             Url      = addSpotViewModel.Url,
             Password = addSpotViewModel.Password
         };
         context.Markers.Add(newMarker);
         context.SaveChanges();
         return(Redirect("/Home"));
     }
     return(View(addSpotViewModel));
 }