コード例 #1
0
        public ActionResult OrderHistory(int?id)
        {
            List <vProductOrder> payment = new List <vProductOrder>();

            try
            {
                payment = BGBCFunctions.ProductOrders().Where(x => x.UserID == ((BGBC.Core.CustomPrincipal)(User)).UserId).OrderByDescending(o => o.TransDate).ToList();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(View(payment));
        }
コード例 #2
0
 public ActionResult ViewOrders(int id)
 {
     return(View(BGBCFunctions.ProductOrders().Where(x => x.ProductID == id).OrderByDescending(s => s.TransDate).ToList()));
 }
コード例 #3
0
        public ActionResult AllProductsOrders(int?id, string sortOrder, string currentFilter, string searchString, int?page, string PageSize)
        {
            if (id != null)
            {
                Product product = _product.Get(id);
                ViewBag.Name = product.Name;
            }
            int currentPageSize = int.Parse(PageSize == null ? "10" : PageSize), pageNumber = (page ?? 1);

            try
            {
                var products = (id == null ? BGBCFunctions.ProductOrders() : BGBCFunctions.ProductOrders().Where(x => x.ProductID == id));

                ViewBag.CurrentSort      = sortOrder;
                ViewBag.DateSortParm     = sortOrder == "Date" ? "date_desc" : "Date";
                ViewBag.TransIDSortParm  = sortOrder == "TransID" ? "TransID_desc" : "TransID";
                ViewBag.CustomerSortParm = sortOrder == "Customer" ? "Customer_desc" : "Customer";
                ViewBag.TypeSortParm     = sortOrder == "Type" ? "Type_desc" : "Type";
                ViewBag.PriceSortParm    = sortOrder == "Price" ? "Price_desc" : "Price";
                ViewBag.NameSortParm     = sortOrder == "Name" ? "name_desc" : "Name";
                ViewBag.CommentsSortParm = sortOrder == "Comments" ? "comments_desc" : "Comments";
                if (PageSize != null)
                {
                    ViewBag.currentPageSize = currentPageSize;
                }


                if (searchString != null)
                {
                    page = 1;
                }
                else
                {
                    searchString = currentFilter;
                }

                ViewBag.CurrentFilter = searchString;
                ViewBag.page          = pageNumber;
                if (!string.IsNullOrEmpty(searchString))
                {
                    products = products.Where(x => x.CustomerFName.Contains(searchString) || x.CustomerLName.Contains(searchString) ||
                                              x.Name.Contains(searchString) || x.TransId.Contains(searchString));
                }
                switch (sortOrder)
                {
                case "date_desc":
                    products = products.OrderByDescending(x => x.TransDate);
                    break;

                case "TransID":
                    products = products.OrderBy(x => x.TransId);
                    break;

                case "TransID_desc":
                    products = products.OrderByDescending(x => x.TransId);
                    break;

                case "Customer":
                    products = products.OrderBy(x => x.CustomerFName);
                    break;

                case "Customer_desc":
                    products = products.OrderByDescending(x => x.CustomerFName);
                    break;

                case "Type":
                    products = products.OrderBy(x => x.UserType);
                    break;

                case "Type_desc":
                    products = products.OrderByDescending(x => x.UserType);
                    break;

                case "Name":
                    products = products.OrderBy(x => x.Name);
                    break;

                case "name_desc":
                    products = products.OrderByDescending(x => x.Name);
                    break;

                case "Price":
                    products = products.OrderBy(x => x.Price);
                    break;

                case "Price_desc":
                    products = products.OrderByDescending(x => x.Price);
                    break;

                case "Comments":
                    products = products.OrderBy(x => x.Comments);
                    break;

                case "comments_desc":
                    products = products.OrderByDescending(x => x.Comments);
                    break;

                default:      // Date ascending
                    products = products.OrderBy(x => x.TransDate);
                    break;
                }

                return(View(products.ToPagedList(pageNumber, currentPageSize)));
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            return(View());
        }