public static int AddRentals(string CostomerName, string MovieName) { int MovieID = RentalsTableHelper.GetMovieID(MovieName); int CustomerID = RentalsTableHelper.GetCustomerID(CostomerName); int nRowsAffected; string strConnectionString = DalUtils.GetConnectionString(); using (SqlConnection connection = new SqlConnection(strConnectionString)) { connection.Open(); StringBuilder sb = new StringBuilder(); sb.Append("insert into Rentals (MovieID,CustomerID) VALUES (@MovieID,@CustomerID)"); String sql = sb.ToString(); using (SqlCommand command = new SqlCommand(sql, connection)) { command.Parameters.AddWithValue("@MovieID", MovieID); command.Parameters.AddWithValue("@CustomerID", CustomerID); nRowsAffected = command.ExecuteNonQuery(); } } return(nRowsAffected); }
public static bool IsTheFilmRented(string MovieName) { int MovieID = RentalsTableHelper.GetMovieID(MovieName); List <Rental> RentalList = GetAllRentalsList(); bool Exsit = RentalList.Exists(property => property.ID == MovieID); return(Exsit); }