コード例 #1
0
        public async Task <IActionResult> Index(string consignee, string mobilePhone, int status = 0, int page = 1)
        {
            int[] s     = { 1, 10, 99 };
            var   query = _context.OrderRecords.AsQueryable().Where(o => s.Contains(o.Status));

            if (!string.IsNullOrEmpty(consignee))
            {
                query = query.Where(o => o.Consignee == consignee);
            }

            if (!string.IsNullOrEmpty(mobilePhone))
            {
                query = query.Where(o => o.MobilePhone == mobilePhone);
            }

            if (status != 0)
            {
                query = query.Where(o => o.Status == status);
            }

            query = query.OrderByDescending(o => o.OrderDate);

            var model = new OrderRecordViewModel();

            model.consignee    = consignee;
            model.mobilePhone  = mobilePhone;
            model.status       = status;
            model.OrderRecords = await query.ToPagedListAsync(20, page);

            return(View(model));
        }
コード例 #2
0
 // GET: UserCenter
 public ActionResult Index()
 {
     var userId = this.HttpContext.User.Identity.GetUserId();
     var vm = new OrderRecordViewModel
     {
         Orders = db.Orders.Where(o => o.UserId.ToString() == userId).ToList()
     };
     return View(vm);
 }