private void Buying(string metoda) { using (DatabasePZEntities db = new DatabasePZEntities()) { GODZINY updateSpot = db.GODZINY.Where(h => h.Godzina == _selectedHour).FirstOrDefault(s => s.Id_Seansu == _seance.SeansID); char[] spots = updateSpot.Miejsca.ToCharArray(); bool canBuying = _spots.Where(n => spots[n.SpotNumber - 1] == '0').Count() != 0; if (canBuying) { foreach (var spot in _spots) { BILET ticket = new BILET() { Potwierdzenie = 0, Imie = _firstName, Nazwisko = _lastName, Email = _email, Telefon = _phoneNumber, Id_Godziny = updateSpot.Id_Godziny, Id_ulga = _selectedDiscount + 1, Realizacja = 0, Miejsce = spot.SpotNumber - 1 }; db.BILET.Add(ticket); spot.IsAvailable = 1; spots[spot.SpotNumber - 1] = '1'; } updateSpot.Miejsca = new string(spots); db.SaveChanges(); // Tutaj bedzie przekierowanie do jakiegos api platnosci karta/gotowka // tresc emaila string trescEmaila = "Tutaj bedzie jakas tresc emaila"; SendEmail email = new SendEmail(); email.SendAsync(_email, "Rezerwacja filmu", trescEmaila); MessageBox.Show("Bilet kupiony - " + metoda); NavigationManager.BackToMain(); } else { { foreach (var spot in _spots) { spot.IsAvailable = 1; } MessageBox.Show("Miejsca zostaly juz przez kogos zarezerwowane. Prosze wybrac inne"); NavigationManager.BackToMain(); } } } }
public UserPageViewModel() { PreviousPageCommand = new RelayCommand(action => { db.SaveChanges(); NavigationManager.NavigateTo(new MainPage()); }); RemoveCommand = new RelayCommand(action => { GODZINY godz = db.GODZINY.FirstOrDefault(n => n.Id_Godziny == SelectedBooking.Id_Godziny); char[] spots = godz.Miejsca.ToCharArray(); spots[(int)SelectedBooking.Miejsce] = '0'; godz.Miejsca = new string(spots); db.SaveChanges(); db.BILET.Remove(SelectedBooking); _bookingList.Remove(SelectedBooking); _filteredBookingList.Refresh(); }); FakeBooking(); }