/// <summary> /// Reads all records in the Requests table in the GAMEGROOVE database. Runs the VIEW_ALL_REQUESTS stored procedure. /// </summary> /// <returns>Returns a list of RequestDOs filled with information retrieved from the database.</returns> public List <RequestDO> ViewRequests() { List <RequestDO> requests = new List <RequestDO>(); //catch errors while accessing the database try { //connect to sql, run stored procedure using (SqlConnection connection = new SqlConnection(_ConnectionString)) using (SqlCommand command = new SqlCommand("VIEW_ALL_REQUESTS", connection)) { command.CommandType = CommandType.StoredProcedure; command.CommandTimeout = 60; connection.Open(); //read from the database using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { RequestDO request = _RequestMapper.MapReaderToSingle(reader); requests.Add(request); } } } } //catch sqlexceptions for accurate logging catch (SqlException ex) { //log error _Logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); throw ex; } // catch further exceptions catch (Exception ex) { //log error _Logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex); throw ex; } finally { } return(requests); }