public async Task <IActionResult> Edit(int id, [Bind("Id,Type")] BokType bokType) { if (id != bokType.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(bokType); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!BokTypeExists(bokType.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(bokType)); }
// GET: Eier/Delete/5 public async Task <IActionResult> DeleteType(int?id) { if (id == null) { return(NotFound()); } BokType type = await _context.BokTyper .SingleOrDefaultAsync(m => m.Id == id); if (type == null) { return(NotFound()); } TypeViewModel model = new TypeViewModel { StatusMessage = StatusMessage, Navn = type.Type, Id = type.Id }; return(View(model)); }
public async Task <IActionResult> DeleteBokConfirmed(int id) { BokType type = await _context.BokTyper.SingleOrDefaultAsync(m => m.Id == id); _context.BokTyper.Remove(type); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Type))); }
public async Task <IActionResult> Create([Bind("Id,Type")] BokType bokType) { if (ModelState.IsValid) { _context.Add(bokType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(bokType)); }
public async Task <IActionResult> Type(TypeViewModel model) { if (!ModelState.IsValid) { return(View(model)); } BokType bokType = new BokType { Type = model.Navn }; await _context.BokTyper.AddAsync(bokType); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Type))); }