public async Task <IActionResult> Edit(int id, [Bind("Id")] LocationAndUserViewModel locationAndUserViewModel) { if (id != locationAndUserViewModel.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(locationAndUserViewModel); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationAndUserViewModelExists(locationAndUserViewModel.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(locationAndUserViewModel)); }
public async Task <IActionResult> Create([Bind("Id")] LocationAndUserViewModel locationAndUserViewModel) { if (ModelState.IsValid) { _context.Add(locationAndUserViewModel); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(locationAndUserViewModel)); }