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));
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
 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));
 }