示例#1
0
        public ActionResult Index()
        {
            var servicePro       = new ProductsService();
            var servicePh        = new ProductPhotoService();
            var BestProducts     = servicePro.GetBestProducts();
            var NewProducts      = servicePro.GetNewProducts();
            var BestProductsList = new List <ProductPhoto>();
            var BestProductsName = new List <Products>();
            var NewProductsList  = new List <ProductPhoto>();
            var NewProductsName  = new List <Products>();

            foreach (var item in BestProducts)
            {
                BestProductsList.Add(servicePh.FindPicById(item.ProductID));
            }
            foreach (var item in NewProducts)
            {
                NewProductsList.Add(servicePh.FindPicById(item.ProductID));
            }

            var NewProductsList2 = new List <string>();

            foreach (var item in NewProductsList)
            {
                if (NewProductsList2.Any((x) => x == item.PhotoPath) == false)
                {
                    NewProductsList2.Add(item.PhotoPath);
                    NewProductsName.Add(servicePro.FindByID(item.ProductID));
                }
            }

            var BestProductsList2 = new List <string>();

            foreach (var item in BestProductsList)
            {
                if (BestProductsList2.Any((x) => x == item.PhotoPath) == false)
                {
                    BestProductsList2.Add(item.PhotoPath);
                    BestProductsName.Add(servicePro.FindByID(item.ProductID));
                }
            }

            ViewData.Add("BestProductsList2", BestProductsList2);
            ViewData.Add("Bestcount", BestProductsList2.Count());
            ViewData.Add("BestProductsName", BestProductsName);
            ViewData.Add("NewProductsList2", NewProductsList2);
            ViewData.Add("Newcount", NewProductsList2.Count());
            ViewData.Add("NewProductsName", NewProductsName);
            return(View());
        }
示例#2
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));
        }
        // GET: Home
        public ActionResult AdminHome()
        {
            if ((bool?)Session["AdminLogin"] == null)
            {
                return(RedirectToAction("AdminHomeLogin"));
            }

            var serviceCus = new CustomerService();
            var serviceOd  = new OrderDetailsService();
            var serviceOr  = new OrderService();
            var servicePro = new ProductsService();

            ViewBag.CostomerNumber = serviceCus.GetAll().Count();
            ViewBag.OrderNumber    = serviceOr.GetAll().Count();
            var ProductNumber = serviceOd.GetAll();
            var Number        = 0;

            foreach (var item in ProductNumber)
            {
                Number += item.Quantity;
            }
            ViewBag.ProductNumber = Number;
            var     GetAllOrder = serviceOd.GetAll();
            decimal total       = 0;

            foreach (var item in GetAllOrder)
            {
                total += servicePro.FindByID(item.ProductID).UnitPrice *item.Quantity;
            }
            ViewBag.Total = Decimal.Round(total);

            return(View());
        }
示例#4
0
        public ActionResult payment()
        {
            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 shopping_service = new ShoppingcartDetailsService();
            var product_service  = new ProductsService();

            var user   = customer_service.FindByCustomerAccount(ticket.Name);
            var items  = shopping_service.FindByCustomer(user.CustomerID);
            var result = new List <decimal>();

            foreach (var item in items)
            {
                result.Add(product_service.FindByID(item.ProductID).UnitPrice *item.Quantity);
            }

            ViewBag.Total = result.Sum();

            return(View());
        }
示例#5
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));
        }