Beispiel #1
0
        /// <summary>
        /// We make a list of the orders avaiable and return the list
        /// </summary>
        /// <returns></returns>
        public List <OrderDO> ViewOrders()
        {
            List <OrderDO> orderList = new List <OrderDO>();

            try
            {
                using (SqlConnection OrderConnection = new SqlConnection(_ConnectionString))
                    using (SqlCommand ViewOrders = new SqlCommand("VIEW_ORDER", OrderConnection))

                    {
                        ViewOrders.CommandType = CommandType.StoredProcedure;
                        OrderConnection.Open();
                        using (SqlDataReader sqlReader = ViewOrders.ExecuteReader())
                        {
                            while (sqlReader.Read())
                            {
                                OrderDO order = mapper.MapReadertoSingle(sqlReader);
                                orderList.Add(order);
                            }
                        }
                    }
            }
            catch (SqlException sqlex)
            {
                _Logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, sqlex);
            }
            catch (Exception ex)
            {
                _Logger.ErrorLog(MethodBase.GetCurrentMethod().DeclaringType.Name, MethodBase.GetCurrentMethod().Name, ex);
            }
            return(orderList);
        }