public async Task <IActionResult> Edit(int id, [Bind("KurierId,Imie,Nazwisko,Pesel,Telefon,RejonId")] Kurier kurier) { if (id != kurier.KurierId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(kurier); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!KurierExists(kurier.KurierId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } IEnumerable <SelectListItem> rejony = _context.Rejony.Select(x => new SelectListItem { Value = x.RejonId.ToString(), Text = x.Nazwa }); ViewData["RejonId"] = new SelectList(rejony, "Value", "Text"); return(View(kurier)); }
public async Task <IActionResult> Create([Bind("KurierId,Imie,Nazwisko,Pesel,Telefon,RejonId")] Kurier kurier) { if (ModelState.IsValid) { _context.Add(kurier); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } IEnumerable <SelectListItem> rejony = _context.Rejony.Select(x => new SelectListItem { Value = x.RejonId.ToString(), Text = x.Nazwa }); ViewData["RejonId"] = new SelectList(rejony, "Value", "Text"); return(View(kurier)); }