public async Task <IActionResult> DeleteConfirmed(CjenovnikItem cj) { _context.CjenovnikItem.Remove(cj); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); }
public async Task <IActionResult> Create(CjenovnikItem cjItem) { if (ModelState.IsValid) { _context.Add(cjItem); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(cjItem)); }
// GET: Cjenovnik/Create public IActionResult Create() { CjenovnikItem cjItem = new CjenovnikItem(); cjItem.CjenovnikId = Cjenovnik.DajCjenovnik().Id; if (cjItem.CjenovnikId < 1) { cjItem.CjenovnikId = 1; } return(View()); }
// GET: Cjenovnik/Delete/5 public async Task <IActionResult> Delete(int?id) { if (id == null) { return(NotFound()); } CjenovnikItem cj = new CjenovnikItem(); cj = await _context.CjenovnikItem.FirstAsync(x => x.Id == id); if (cj == null) { return(NotFound()); } return(View(cj)); }
public async Task <IActionResult> Edit(CjenovnikItem cjenovnikItem) { if (ModelState.IsValid) { try { _context.Update(cjenovnikItem); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!CjenovnikExists(cjenovnikItem.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(cjenovnikItem)); }