Пример #1
0
        public ActionResult SearchOrderdetail(int orderid)
        {
            var cookie = Request.Cookies[FormsAuthentication.FormsCookieName];

            if (cookie == null)
            {
                return(RedirectToAction("Login", "Login"));
            }

            var ticket = FormsAuthentication.Decrypt(cookie.Value);

            var customer_service    = new CustomerService();
            var product_service     = new ProductsService();
            var orderdetail_service = new OrderDetailsService();
            var photo_service       = new ProductPhotoService();
            var order_service       = new OrderService();

            var user  = customer_service.FindByCustomerAccount(ticket.Name);
            var items = orderdetail_service.FindById(orderid);

            if (user.CustomerID != order_service.FindById(orderid).CustomerID)
            {
                return(RedirectToAction("Index", "Home"));
            }

            var result = new List <SearchOrderdetailModel>();

            foreach (var item in items)
            {
                SearchOrderdetailModel model = new SearchOrderdetailModel();

                model.Image       = photo_service.FindById(item.ProductID).First().PhotoPath;
                model.ProductID   = item.ProductID;
                model.ProductName = product_service.FindByID(item.ProductID).ProductName;
                model.Color       = product_service.FindByID(item.ProductID).Color;
                model.Size        = product_service.FindByID(item.ProductID).Size;
                model.Amount      = item.Quantity;
                model.UnitPrice   = product_service.FindByID(item.ProductID).UnitPrice;
                model.Total       = product_service.FindByID(item.ProductID).UnitPrice *item.Quantity;

                result.Add(model);
            }

            ViewData.Add("list", result);
            var orders = order_service.FindById(orderid);

            return(View(orders));
        }
Пример #2
0
        public ActionResult Search(string sortmethod)
        {
            var str          = this.ControllerContext.HttpContext.Request.QueryString[0];
            var service      = new ProductsService();
            var photoService = new ProductPhotoService();
            var list         = service.GetAll().ToList();
            var query        = new List <Products>();

            foreach (var item in list)
            {
                if (item.ProductName.Contains(str) && query.Any((x) => x.ProductName == item.ProductName) == false)
                {
                    query.Add(item);
                }
            }

            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());
        }
Пример #3
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());
        }
Пример #4
0
        public ActionResult AdminProductUpdate(int id)
        {
            var productservice = new ProductsService();
            var photoservice   = new ProductPhotoService();
            var product        = productservice.FindByID(id);
            var items          = photoservice.FindById(id);
            var result         = new List <ProductPhoto>();

            foreach (var item in items)
            {
                var photo = new ProductPhoto()
                {
                    PhotoID   = item.PhotoID,
                    PhotoPath = item.PhotoPath
                };

                result.Add(photo);
            }

            var model = new AdminProductUpdate()
            {
                ProductID      = id,
                ProductName    = product.ProductName,
                UnitPrice      = Decimal.Round(product.UnitPrice),
                CategoryID     = product.CategoryID,
                ProductDetails = product.ProductDetails,
                Size           = product.Size,
                Color          = product.Color,
                UnitsInStock   = product.UnitsInStock
            };

            ViewBag.list      = result;
            ViewBag.productid = id;

            return(View(model));
        }