public async Task <ActionResult <Dopust> > PostDopust(Dopust dopust) { _context.Dopusti.Add(dopust); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDopust", new { id = dopust.ID }, dopust)); }
public async Task <IActionResult> PutDopust(int id, Dopust dopust) { if (id != dopust.ID) { return(BadRequest()); } _context.Entry(dopust).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DopustExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Edit(int id, [Bind("ID,Datum,UraZacetka,UraKonca")] Dopust dopust) { if (id != dopust.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(dopust); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DopustExists(dopust.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(dopust)); }
public async Task <IActionResult> Create([Bind("ID,Datum,UraZacetka,UraKonca")] Dopust dopust) { var currentUser = await _usermanager.GetUserAsync(User); if (ModelState.IsValid) { dopust.Uporabnik = currentUser; _context.Add(dopust); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(dopust)); }