public async Task <IActionResult> PutRoom(int id, Room room) { if (id != room.Id) { return(BadRequest()); } _context.Entry(room).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!RoomExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("Id,Name,Length,Width")] Room room) { if (ModelState.IsValid) { _context.Add(room); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(room)); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } var room = await _context.Room.FindAsync(id); if (room == null) { return(NotFound()); } try { _context.Room.Remove(room); await _context.SaveChangesAsync(); return(RedirectToPage("./Index")); } catch (DbUpdateException) { return(RedirectToAction("./Delete", new { id, saveChangesError = true })); } }