public List<ProvisionalBooking> GetAllConfirmedBookings() { List<ProvisionalBooking> listAllConfirmedBookings = null; using (DataTable table = DBHelper.ExecuteSelectCommand("sp_GetConfirmedBookings", CommandType.StoredProcedure)) { if (table.Rows.Count > 0) { listAllConfirmedBookings = new List<ProvisionalBooking>(); foreach (DataRow row in table.Rows) { ProvisionalBooking provisionalBooking = new ProvisionalBooking(); provisionalBooking.BookingID = Convert.ToInt32(row["BookingID"]); provisionalBooking.Name = row["Name"].ToString(); provisionalBooking.ArriveDate = Convert.ToDateTime(row["ArriveDate"]); provisionalBooking.DepartDate = Convert.ToDateTime(row["DepartDate"]); listAllConfirmedBookings.Add(provisionalBooking); } } } return listAllConfirmedBookings; }
public ProvisionalBooking GetProvisionalBookingDetails(int bookingID) { ProvisionalBooking provisionalBooking = null; SqlParameter[] paramaters = new SqlParameter[] { new SqlParameter("@BookingID", bookingID), }; using (DataTable table = DBHelper.ExecuteParamerizedSelectCommand("sp_GetProvisionalBookingDetails", CommandType.StoredProcedure, paramaters)) { if (table.Rows.Count == 1) { DataRow row = table.Rows[0]; provisionalBooking = new ProvisionalBooking(); provisionalBooking.Name = row["Name"].ToString(); provisionalBooking.Email = row["Email"].ToString(); provisionalBooking.PhoneNo = row["PhoneNo"].ToString(); provisionalBooking.ArriveDate = Convert.ToDateTime(row["ArriveDate"]); provisionalBooking.DepartDate = Convert.ToDateTime(row["DepartDate"]); try { provisionalBooking.ProofOfPayment = row["ProofOfPayment"].ToString(); } catch (NullReferenceException) { provisionalBooking.ProofOfPayment = null; } } } return provisionalBooking; }