private void BtnUpdate_Click(object sender, RoutedEventArgs e) { if (loginService.IsSuperUser) { if (TxtCustID.Text.Equals("") || TxtFlightID.Text.Equals("")) { MessageBox.Show("All Fields Required", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); } else { if (MessageBox.Show("Are you sure to update this passenger?", "Warning", MessageBoxButton.YesNo, MessageBoxImage.Exclamation) == MessageBoxResult.Yes) { try { Passenger ps = new Passenger(LstPassengers.SelectedIndex, int.Parse(TxtCustID.Text), int.Parse(TxtFlightID.Text)); passengerService.Update(ps); RefreshList(); } catch (Exception ex) { MessageBox.Show("Please enter an integer for ID", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } } } else { MessageBox.Show("Access Denied", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public async Task <ActionResult <Passenger> > Update(string id, Passenger passengerIn) { var passenger = _passengerService.Get(id); if (passenger == null) { return(NotFound()); } await _passengerService.Update(id, passengerIn); return(_passengerService.Get(id)); }
public async Task TestUpdate() { var newAge = _testPassenger.Age + 1; await TestCreate(); var passenger = _passengerService.Get(_testPassenger.Id); passenger.Age = newAge; await _passengerService.Update(passenger.Id, passenger); var actual = _passengerService.Get(_testPassenger.Id); Assert.AreNotEqual(_testPassenger, actual, "Database update did not modify the passenger"); Assert.AreEqual(passenger, actual, "Database returned a different passenger than the modified one"); }