public async Task <IActionResult> Edit(string id, [Bind("CustomerId,AtractionId")] CustomerAtraction customerAtraction) { if (id != customerAtraction.CustomerId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(customerAtraction); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CustomerAtractionExists(customerAtraction.CustomerId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["AtractionId"] = new SelectList(_context.Atractions, "Id", "Id", customerAtraction.AtractionId); ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Id", customerAtraction.CustomerId); return(View(customerAtraction)); }
public async Task <IActionResult> Create([Bind("CustomerId,AtractionId")] CustomerAtraction customerAtraction) { if (ModelState.IsValid) { _context.Add(customerAtraction); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["AtractionId"] = new SelectList(_context.Atractions, "Id", "Id", customerAtraction.AtractionId); ViewData["CustomerId"] = new SelectList(_context.Customer, "Id", "Id", customerAtraction.CustomerId); return(View(customerAtraction)); }