public StandingTeeTimeRequest GetReservedStandingTeeTime(string DayOfWeek, DateTime requestedTime, DateTime requestedStartDate, DateTime requestedEndDate) { StandingTeeTimeRequest standingteetimerequest = new StandingTeeTimeRequest(); SqlConnection ClubBaistConnection = new SqlConnection(); ClubBaistConnection.ConnectionString = @"Data Source= (LocalDB)\MSSQLLocalDB; Initial Catalog = aspnet-ClubBaistGolfManagement-53bc9b9d-9d6a-45d4-8429-2a2761773502; Integrated Security = True; MultipleActiveResultSets=True"; SqlCommand thecommand = new SqlCommand(); thecommand.CommandType = CommandType.StoredProcedure; thecommand.Connection = ClubBaistConnection; thecommand.CommandText = "GetReservedStandingTeeTime"; SqlParameter day = new SqlParameter(); day.ParameterName = "@dayofweek"; day.SqlDbType = SqlDbType.VarChar; day.Value = DayOfWeek; day.Direction = ParameterDirection.Input; thecommand.Parameters.Add(day); SqlParameter time = new SqlParameter(); time.ParameterName = "@time"; time.SqlDbType = SqlDbType.Time; time.Value = requestedTime; time.Direction = ParameterDirection.Input; thecommand.Parameters.Add(time); SqlParameter startDate = new SqlParameter(); startDate.ParameterName = "@startDate"; startDate.SqlDbType = SqlDbType.Date; startDate.Value = requestedStartDate; startDate.Direction = ParameterDirection.Input; thecommand.Parameters.Add(startDate); SqlParameter endDate = new SqlParameter(); endDate.ParameterName = "@endDate"; endDate.SqlDbType = SqlDbType.Date; endDate.Value = requestedEndDate; endDate.Direction = ParameterDirection.Input; thecommand.Parameters.Add(endDate); ClubBaistConnection.Open(); SqlDataReader theDataReader; theDataReader = thecommand.ExecuteReader(); CBSUsers UserManager = new CBSUsers(); if (theDataReader.HasRows) { while (theDataReader.Read()) { standingteetimerequest.RequestedTime = DateTime.Parse(theDataReader["RequestedTeeTime"].ToString()); standingteetimerequest.DayofWeek = theDataReader["DayofWeek"].ToString(); standingteetimerequest.RequestedEndDate = DateTime.Parse(theDataReader["RequestedEndDate"].ToString()); standingteetimerequest.Shareholder1 = !string.IsNullOrEmpty(theDataReader["Shareholder1Number"].ToString()) ? UserManager.GetUser((string)(theDataReader["Shareholder1Number"])) : new Shareholder(); standingteetimerequest.Shareholder2 = !string.IsNullOrEmpty(theDataReader["Shareholder2Number"].ToString()) ? UserManager.GetUser((string)(theDataReader["Shareholder2Number"])) : new Shareholder(); standingteetimerequest.Shareholder3 = !string.IsNullOrEmpty(theDataReader["Shareholder3Number"].ToString()) ? UserManager.GetUser((string)(theDataReader["Shareholder3Number"])) : new Shareholder(); standingteetimerequest.Shareholder4 = !string.IsNullOrEmpty(theDataReader["Shareholder4Number"].ToString()) ? UserManager.GetUser((string)(theDataReader["Shareholder4Number"])) : new Shareholder(); } theDataReader.Close(); ClubBaistConnection.Close(); } return(standingteetimerequest); }