public ActionResult Create([Bind(Include = "Id,Type,Latitude,Longitude,Status,Location,Description,IsControllable,IsWorking")] MarkerModel model) { var types = GetAllTypes(); var statuses = GetStatus(); model.Types = GetSelectListItems(types); model.Statuses = GetSelectListItems(statuses); if (ModelState.IsValid) { db.Markers.Add(model); db.SaveChanges(); return(RedirectToAction("SaveToFirebase", new { mId = model.Id })); } return(View(model)); }
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)); }