public bool CancelBooking(Booking booking) { IBookingComponent component = new BookingComponent(); try { component.CancelBooking(booking); } catch(Exception e) { throw new FaultException(e.Message); } return true; }
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { try { using (IBookingComponent bookingservice = new BookingComponent()) { Booking booking = new Booking(); booking.ID = int.Parse(GridView1.DataKeys[Int32.Parse(e.CommandArgument.ToString())].Value.ToString()); bookingservice.CancelBooking(booking); lblID.Text = "Your Booking has been cnaceled"; RefreshGridView(); } } catch (Exception ex) { throw new Exception (ex.Message); } }
protected void btncancel_Click(object sender, EventArgs e) { IBookingComponent bookingservice = new BookingComponent(); Booking booking = new Booking(); try { booking.ID = int.Parse(lblID.Text); bookingservice.CancelBooking(booking); lblstatus.Text = "Your Booking has been successfully canceled."; } catch (Exception) { throw; } }