public async Task <IActionResult> Edit(int id, [Bind("ID,Name,ImagePath,Description")] VacationIdeas vacationIdeas) { if (id != vacationIdeas.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(vacationIdeas); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VacationIdeasExists(vacationIdeas.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(vacationIdeas)); }
//This SECOND Create takes the information from the FORM and adds it to the database using the _context.Add and _context.SaveChanges. public async Task <IActionResult> Create([Bind("ID,Name,ImagePath,Description")] VacationIdeas vacationIdeas) { if (ModelState.IsValid) { _context.Add(vacationIdeas); //THIS is where the vacation ideas are added. await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(vacationIdeas)); }