public IActionResult ShowTrip(int id) { var trip = _context.Trip.FirstOrDefault(x => x.Id == id); var model = new ShowTripViewModel() { Id = id, Name = trip.Name, StartDate = trip.StartDate, StartPlace = trip.StartPlace, FinishPlace = trip.FinishPlace, Distance = trip.Distance, Days = trip.Days }; return(View(model)); }
public IActionResult EditTrip(ShowTripViewModel model) { var trip = _context.Trip.FirstOrDefault(x => x.Id == model.Id); if (ModelState.IsValid) { trip.Name = model.Name; trip.StartDate = model.StartDate; trip.StartPlace = model.StartPlace; trip.FinishPlace = model.FinishPlace; trip.Distance = model.Distance; trip.Days = model.Days; _context.Trip.Update(trip); _context.SaveChanges(); return(RedirectToAction("Index")); } return(View(model)); }