예제 #1
0
        public void OnGet(string option = null, string search = null)
        {
            if (search != null)
            {
                var user = new ApplicationUser();
                List <OrderHeader> OrderHeaderList = new List <OrderHeader>();

                if (option.Equals("order"))
                {
                    OrderHeaderList = _db.OrderHeader.Where(o => o.Id.Equals(Convert.ToInt32(search))).ToList();
                }
                else if (option.Equals("email"))
                {
                    user = _db.Users.Where(u => u.Email.ToLower().Contains(search.ToLower())).FirstOrDefault();
                }
                else if (option.Equals("phone"))
                {
                    user = _db.Users.Where(u => u.PhoneNumber.ToLower().Contains(search.ToLower())).FirstOrDefault();
                }
                else if (option.Equals("name"))
                {
                    user = _db.Users.Where(u => u.FirstName.ToLower().Contains(search.ToLower()) || u.LastName.ToLower().Contains(search.ToLower())).FirstOrDefault();
                }

                if (user != null || OrderHeaderList.Count > 0)
                {
                    if (OrderHeaderList.Count.Equals(0))
                    {
                        OrderHeaderList = _db.OrderHeader.Where(o => o.UserId.Equals(user.Id)).OrderByDescending(x => x.PickUpTime).ToList();
                    }

                    foreach (OrderHeader item in OrderHeaderList)
                    {
                        OrderDetailViewModel individual = new ViewModel.OrderDetailViewModel();
                        individual.OrderDetail = _db.OrderDetail.Where(x => x.OrderId == item.Id).ToList();
                        individual.OrderHeader = item;

                        OrderDetailViewModel.Add(individual);
                    }
                }
            }
            else
            {
                List <OrderHeader> OrderHeaderList = _db.OrderHeader.Where(u => u.Status.Equals(SD.StatusReady)).OrderByDescending(X => X.OrderDate).ToList();

                foreach (OrderHeader item in OrderHeaderList)
                {
                    OrderDetailViewModel individual = new ViewModel.OrderDetailViewModel();
                    individual.OrderDetail = _db.OrderDetail.Where(x => x.OrderId == item.Id).ToList();
                    individual.OrderHeader = item;

                    OrderDetailViewModel.Add(individual);
                }
            }
        }
예제 #2
0
        public void OnGet()
        {
            List <OrderHeader> OrderHeaderList = _db.OrderHeader.Where(u => u.Status != SD.StatusCompleted && u.Status != SD.StatusReady && u.Status != SD.StatusCancelled).OrderByDescending(X => X.OrderDate).ToList();

            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailViewModel individual = new ViewModel.OrderDetailViewModel();
                individual.OrderDetail = _db.OrderDetail.Where(x => x.OrderId == item.Id).ToList();
                individual.OrderHeader = item;

                OrderDetailViewModel.Add(individual);
            }
        }
예제 #3
0
        //if id=0 display only 5 past orders else display all the orders.
        public void OnGet(int id = 0)
        {
            var claimsIdentity = (ClaimsIdentity)this.User.Identity;
            var claim          = claimsIdentity.FindFirst(ClaimTypes.NameIdentifier);

            OrderDetailViewModel = new List <OrderDetailViewModel>();

            List <OrderHeader> OrderHeaderList = _db.OrderHeader.Where(u => u.UserId == claim.Value).OrderByDescending(x => x.OrderDate).ToList();

            if (id == 0)
            {
                OrderHeaderList = OrderHeaderList.Take(5).ToList();
            }

            foreach (OrderHeader item in OrderHeaderList)
            {
                OrderDetailViewModel individual = new ViewModel.OrderDetailViewModel();
                individual.OrderHeader = item;
                individual.OrderDetail = _db.OrderDetail.Where(o => o.Id == item.Id).ToList();

                OrderDetailViewModel.Add(individual);
            }
        }