public IActionResult Create([Bind("OsobaId,Ime,Prezime,Adresa")] Osoba osoba) { if (ModelState.IsValid) { db.Add(osoba); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } return(View(osoba)); }
public async Task <IActionResult> Create([Bind("OsobaId,Ime,Prezime,Adresa")] Osoba osoba) { if (ModelState.IsValid) { _context.Add(osoba); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(osoba)); }
public IActionResult Create([Bind("OsobaId,Ime,Prezime,Telefon")] Osoba osoba) { if (ModelState.IsValid) { try { db.Add(osoba); db.SaveChanges(); return(RedirectToAction(nameof(Index))); } catch (Exception) { ViewBag.Greska = "Greska pri cuvanju podataka"; } } return(View(osoba)); }