public async Task <IActionResult> Edit(int id, [Bind("Id,StartDate,EndDate,Comment,TravelDestinationId")] TravelMemory travelMemory) { if (id != travelMemory.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(travelMemory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TravelMemoryExists(travelMemory.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["TravelDestinationId"] = new SelectList(_context.TravelDestinations, "Id", "Id", travelMemory.TravelDestinationId); return(View(travelMemory)); }
public async Task <IActionResult> Create([Bind("Id,StartDate,EndDate,Comment,TravelDestinationId")] TravelMemory travelMemory) { if (ModelState.IsValid) { _context.Add(travelMemory); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["TravelDestinationId"] = new SelectList(_context.TravelDestinations, "Id", "Id", travelMemory.TravelDestinationId); return(View(travelMemory)); }