Example #1
0
        public ActionResult Accessories(string sortmethod)
        {
            var service      = new CategoriesService();
            var photoService = new ProductPhotoService();
            var query        = service.ClassifyByCategoryNameAndNullDownTime("飾品");

            query = query.Where((x) => x.Downtime == null).ToList();
            if (sortmethod != null)
            {
                if (sortmethod == "Time")
                {
                    query = query.OrderByDescending((x) => x.Uptime).ToList();
                }
                if (sortmethod == "TimeDESC")
                {
                    query = query.OrderBy((x) => x.Uptime).ToList();
                }
                if (sortmethod == "Price")
                {
                    query = query.OrderByDescending((x) => x.UnitPrice).ToList();
                }
                if (sortmethod == "PriceDESC")
                {
                    query = query.OrderBy((x) => x.UnitPrice).ToList();
                }
            }

            var photo_list = new List <ProductPhoto>();

            foreach (var item in query)
            {
                photo_list.Add(photoService.FindById(item.ProductID).First());
            }

            ViewData.Add("photo_list", photo_list);
            ViewData.Add("count", query.Count());
            ViewData.Add("list", query);
            return(View());
        }