public AuditoriumView(Auditorium auditorium, List<Seat> occupiedSeats) { Rows = new List<AuditoriumRow>(); for (var i = 0; i < auditorium.Rows; i++) { var row = new AuditoriumRow { Seats = new List<AuditoriumSeat>(), Number = i + 1 }; for (var j = 0; j < auditorium.Seats; j++) { var seat = new AuditoriumSeat { Row = row, SeatNumber = j + 1, IsFree = true }; seat.PropertyChanged += SeatOnPropertyChanged; row.Seats.Add(seat); } Rows.Add(row); } foreach (var seat in occupiedSeats) { Rows[seat.RowNumber - 1].Seats[seat.SeatNumber - 1].IsFree = false; } }
public void Delete(Auditorium auditorium) { var executor = new CommandExecutor("dbo.DeleteAuditorium", connectionString); executor.SetParam("@Id", auditorium.Id, SqlDbType.Int); executor.ExecuteCommand(true).ThrowIfException(); }
public AuditoriumEditorWindowViewModel(Auditorium auditorium, ShowtimeRepository repository) { if (auditorium == null) { createMode = true; auditorium = new Auditorium(); } Auditorium = auditorium; this.repository = repository; }
public AuditoriumEditorWindow(Auditorium auditorium) { InitializeComponent(); var connectionString = ConnectionStringBuilder.Build( Settings.Default.server, Settings.Default.database, Settings.Default.user, Settings.Default.password); var repository = new ShowtimeRepository(connectionString); viewModel = new AuditoriumEditorWindowViewModel(auditorium, repository); DataContext = viewModel; }
public void DeleteGenre(Auditorium auditorium) { var result = MessageBox.Show( string.Format(Resources.DeleteAuditoriumConfirmationText, auditorium.Name), Resources.DeleteConfirmationCaption, MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { try { repository.Delete(auditorium); RetrieveData(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void OpenGenreEditor(Auditorium auditorium) { try { if (auditorium != null) { auditorium = auditorium.Clone(); } var editor = new AuditoriumEditorWindow(auditorium); var result = editor.ShowDialog(); if (result.HasValue && result.Value) { RetrieveData(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public void Save(Auditorium auditorium, bool update) { CommandExecutor executor; if (update) { executor = new CommandExecutor("dbo.UpdateAuditorium", connectionString); executor.SetParam("@Id", auditorium.Id, SqlDbType.Int); } else { executor = new CommandExecutor("dbo.CreateAuditorium", connectionString); } executor.SetParam("@Name", auditorium.Name, SqlDbType.NVarChar); executor.SetParam("@Rows", auditorium.Rows, SqlDbType.Int); executor.SetParam("@Seats", auditorium.Seats, SqlDbType.Int); executor.ExecuteCommand(true).ThrowIfException(); }