public Task UrediBankara(Bankar bankar) { if (nivoPristupa != 2) { throw new AuthenticationException(); } return(bankari.UrediBankara(bankar)); }
public async Task <IActionResult> Create([Bind("Ime,Prezime,KorisnickoIme,Lozinka,MjestoZaposlenja")] Bankar bankar) { korisnik = await LoginUtils.Authenticate(Request, Context, this); if (korisnik == null) { return(RedirectToAction("Logout", "Login", new { area = "" })); } _bankari.Pristupi(korisnik); ViewData["Ime"] = korisnik.Ime; if (ModelState.IsValid) { await _bankari.DodajBankara(bankar); return(RedirectToAction(nameof(Index))); } return(View(bankar)); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Ime,Prezime,KorisnickoIme,Lozinka,MjestoZaposlenja")] Bankar bankar) { korisnik = await LoginUtils.Authenticate(Request, Context, this); if (korisnik == null) { return(RedirectToAction("Logout", "Login", new { area = "" })); } _bankari.Pristupi(korisnik); ViewData["Ime"] = korisnik.Ime; if (id != bankar.Id) { return(NotFound()); } if (ModelState.IsValid) { try { await _bankari.UrediBankara(bankar); } catch (DbUpdateConcurrencyException) { if (!BankarExists(bankar.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bankar)); }
public async Task UrediBankara(Bankar bankar) { _context.Update(bankar); await _context.SaveChangesAsync(); }
public async Task DodajBankara(Bankar bankar) { _context.Add(bankar); await _context.SaveChangesAsync(); }
public async Task <Bankar> DajBankara(int?id) { Bankar bankar = await _context.Bankar.Include("MjestoZaposlenja").Where(m => m.Id == id).FirstAsync(); return(bankar); }