Exemplo n.º 1
0
 public ActionResult Edit(AttractionEditViewModel attractionEdit)
 {
     var updatedAttraction = db.Attraction.Include(a => a.AttractionType).Include(c => c.Country).Include(c => c.Coordinates).Include(a => a.Address).Where(x => x.ID == attractionEdit.Attraction.ID).SingleOrDefault();
     updatedAttraction.AttractionType = db.AttractionType.Find(attractionEdit.Attraction.AttractionType.ID);
     updatedAttraction.Country = db.Country.Find(attractionEdit.Attraction.Country.ID);
     updatedAttraction.Coordinates.Latitude = attractionEdit.Attraction.Coordinates.Latitude;
     updatedAttraction.Coordinates.Longitude = attractionEdit.Attraction.Coordinates.Longitude;
     updatedAttraction.Address = attractionEdit.Attraction.Address;
     db.Entry(updatedAttraction).State = EntityState.Modified;
     db.SaveChanges();
     return RedirectToAction("Details", new { id = updatedAttraction.ID });
 }
Exemplo n.º 2
0
 public ActionResult Edit(int id)
 {
     ViewBag.AttractionTypes = DbHelpers.GetAttractionTypesToList();
     ViewBag.Countries = DbHelpers.GetCountriesToList();
     Attraction attraction = db.Attraction.Include(c => c.Country).Include(t => t.AttractionType).Include(c => c.Coordinates).Include(a => a.Address).Include(i => i.Images).Where(a => a.ID == id).SingleOrDefault();
     AttractionEditViewModel attractionEdit = new AttractionEditViewModel();
     attractionEdit.Attraction = attraction;
     return View(attractionEdit);
 }