public List <CustomerTour_Model> ShowAllBookedTours()//New { Connection(); SqlDataReader reader; List <CustomerTour_Model> toursBookedList = new List <CustomerTour_Model>(); SqlCommand cmd = new SqlCommand("uspShowAllCustomerTours", con); cmd.CommandType = CommandType.StoredProcedure; try { con.Open(); reader = cmd.ExecuteReader(); while (reader.Read()) { CustomerTour_Model toursbooked = new CustomerTour_Model(); toursbooked.TourArea = reader["TourArea"].ToString(); toursbooked.Email = reader["Email"].ToString(); toursbooked.DateOfTour = DateTime.Parse(reader["DateOfTour"].ToString()); toursbooked.NumberOfPeople = int.Parse(reader["NumberOfPeople"].ToString()); toursBookedList.Add(toursbooked); } } catch (Exception ex) { message = "Error " + ex.Message; } finally { con.Close(); } return(toursBookedList); }
public int InsertCustomerTour(CustomerTour_Model customerTour) { Connection(); int count = 0; SqlCommand cmd = new SqlCommand("uspInsertIntoCustomerTour", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@TourArea", customerTour.TourArea); cmd.Parameters.AddWithValue("@Email", customerTour.Email); cmd.Parameters.AddWithValue("@DateOfTour", customerTour.DateOfTour); cmd.Parameters.AddWithValue("@NumberOfPeople", customerTour.NumberOfPeople); try { con.Open(); count = cmd.ExecuteNonQuery(); } catch (Exception ex) { message = ex.Message; } finally { con.Close(); } return(count); }