public Booking GetBookingById(string id) { Booking booking = new Booking(); int idConverted; bool success = int.TryParse(id, out idConverted); if (success == false) { throw new WebFaultException <string>("Please input a number instead ", HttpStatusCode.BadRequest); } try { booking = dataBaseRepository.GetBookingById(idConverted); } catch (Exception ex) { SaveException.Log("webErrors.txt", ex); throw new WebFaultException <string>("Sorry something went wrong when trying to get booking from Database ", HttpStatusCode.InternalServerError); } if (booking == null) { throw new WebFaultException <string>("Sorry no booking found at position " + id, HttpStatusCode.InternalServerError); } return(booking); }
public Booking GetBookingById(int id) { var booking = dataBaseRepository.GetBookingById(id); if (booking == null) { throw new FaultException("Sorry no car booking found"); } return(booking); }