public async Task <IActionResult> Edit(Guid id, [Bind("Id,SeatNumber,Floor,SeatState")] LibrarySeat librarySeat) { if (id != librarySeat.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(librarySeat); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LibrarySeatExists(librarySeat.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(librarySeat)); }
public async Task <IActionResult> Create([Bind("Id,SeatNumber,Floor,SeatState")] LibrarySeat librarySeat) { if (ModelState.IsValid) { librarySeat.Id = Guid.NewGuid(); _context.Add(librarySeat); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(librarySeat)); }
public static LibrarySeat[] CreateLibrarySeat(int floor, int count) { LibrarySeat[] librarySeats = new LibrarySeat[count]; for (int i = 0; i < count; i++) { LibrarySeat seat = new LibrarySeat(); seat.Id = Guid.NewGuid(); seat.Floor = floor; seat.SeatNumber = floor * 100 + i + 1; seat.SeatState = LibrarySeat.SeatStates.Available; librarySeats[i] = seat; } return(librarySeats); }