Ejemplo n.º 1
0
        // GET: Orders
        public ActionResult Index(int? page)
        {
            IEnumerable<OrderElement> ord = new Queue<OrderElement>();

            List<OrderElement> list = new List<OrderElement>();

            var order = from m in db.Orders select m;

            var userId = User.Identity.GetUserId();

            order = order.Where(s => s.UserId == userId);

            var users = from m in dbU.UserInfoes select m;

            users = users.Where(s => s.UserId == userId);

            ViewBag.UserName = users.First().Firstname;
            ViewBag.LastName = users.First().Lastname;

            foreach (var item in order)
            {
                var productId = item.ProductId;

                var product = dbP.SW_Product.Find(productId);

                OrderElement oE = new OrderElement();

                oE.Logo = product.Logo;
                oE.OrderId = item.OrderId;
                oE.ProductId = product.IDProduct;
                oE.ProductName = product.Name;
                oE.ProductPrice = product.Price;
                oE.Tag = product.Tag;
                oE.UserId = item.UserId;
                oE.Date = item.Date;

                ord=list.AsEnumerable<OrderElement>();

                list.Add(oE);
            }

            ViewBag.list = list;

            int pageSize = 5;
            int pageNumber = (page ?? 1);
            return View(ord.ToPagedList(pageNumber, pageSize));
        }