Beispiel #1
0
        public Collection<RequestForm> GetApprovedRequestsBetweenDates(SqlDateTime begin, SqlDateTime end)
        {
            Collection<RequestForm> requestCollection = new Collection<RequestForm>();
            SqlConnection connection = new SqlConnection(_connectionString);
            string commandString = "SELECT [UniqueRequestID] FROM [Intern_CoyoteMoves].[dbo].[RequestData] WHERE [CreateDate] <= @end AND [CreateDate] >= @begin AND [Pending] = 0";
            SqlCommand command = new SqlCommand(commandString);

            command.Parameters.AddWithValue("@begin", begin);
            command.Parameters.AddWithValue("@end", end);
            command.Connection = connection;
            connection.Open();
            SqlDataReader reader = command.ExecuteReader();
            SqlToFormModelFactory RequestFactory = new SqlToFormModelFactory(reader);
            while (reader.Read())
            {
                requestCollection.Add(_requester.RetrieveRequest(reader.GetGuid(reader.GetOrdinal("UniqueRequestID"))));
            }
            connection.Close();
            return requestCollection;
        }
        public RequestForm RetrieveRequest(Guid uniqueRequestID)
        {
            SqlConnection connection = new SqlConnection(_connectionString);
            string commandstring = "EXEC [Intern_CoyoteMoves].[dbo].[spRequestData_GetRequestDataByUniqueID] @guid";
            SqlCommand command = new SqlCommand(commandstring);

            try
            {
                command.Parameters.AddWithValue("@guid", uniqueRequestID);
                command.Connection = connection;
                connection.Open();
                SqlDataReader reader = command.ExecuteReader();
                SqlToFormModelFactory formFactory = new SqlToFormModelFactory(reader);
                return formFactory.GetRequest(uniqueRequestID);
            }

            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }