public PubOrdersViewModel GetPubOrders(int?UserID, int PageNumber)
        {
            SqlParameter @outputParam = new SqlParameter {
                ParameterName = "@outputParam", SqlDbType = SqlDbType.Int, Direction = ParameterDirection.Output
            };

            var results = GetPubOrderResults.FromSqlRaw("EXEC @outputParam=Get_PubOrders @UserID, @PageNumber, @ItemsPerPage",
                                                        outputParam,
                                                        new SqlParameter("@UserID", UserID ?? 0),
                                                        new SqlParameter("@PageNumber", PageNumber),
                                                        new SqlParameter("@ItemsPerPage", GlobalConstants.OrdersPerPage)).ToList();

            if (results.Count() > 0)
            {
                List <UserOrderViewModel> userOrderViewModel = new List <UserOrderViewModel>();
                foreach (Get_PubOrderViewModel order in results)
                {
                    List <Get_PubUserOrderItemsViewModel> items = GetPubUserOrderItems(order.OrderId);
                    userOrderViewModel.Add(new UserOrderViewModel()
                    {
                        OrderDetails = order, OrderTopItems = items
                    });
                }

                return(new PubOrdersViewModel()
                {
                    Orders = userOrderViewModel, RowCount = (int)outputParam.Value
                });
            }
            else
            {
                return(null); //no results returned - order dosen't exist in DB so give nothing.
            }
        }
        public Get_PubOrderViewModel GetPubOrder(int OrderID)
        {
            var results = GetPubOrderResults.FromSqlRaw("EXEC Get_PubOrder @OrderID",
                                                        new SqlParameter("@OrderID", OrderID)).ToList();

            if (results.Count() > 0)
            {
                return(results.First());
            }
            else
            {
                return(null); //no results returned - order dosen't exist in DB so give nothing.
            }
        }