public async Task <IActionResult> SearchOrders(OrderSearchView model) { IQueryable <Order> orders = db.Order.Include(a => a.Address).Include(u => u.User); if (model.filters.OrderId != 0 && model.filters.OrderId != null) { orders = orders.Where(x => x.OrderId == model.filters.OrderId); } if (model.filters.Phone != null) { orders = orders.Where(x => x.User.Login == model.filters.Phone); } if (model.filters.Email != null) { orders = orders.Where(x => x.User.Email == model.filters.Email); } if (model.filters.Date != null) { orders = orders.Where(x => x.OrderDate.ToShortDateString() == model.filters.Date); } if (model.filters.Status != 0) { orders = orders.Where(x => x.Status == model.filters.Status); } if (model.filters.Delivery != "0") { orders = orders.Where(x => x.Delivery == model.filters.Delivery); } model.Orders = await orders.ToListAsync(); return(View("~/Views/Admin/OrderManagement/OrderManagement.cshtml", model)); }
private void ShowOrder(object sender, EventArgs e) { OrderSearchView view = new OrderSearchView { Owner = _View.Form }; view.Show(); }
public async Task <IActionResult> SearchOrders(int?UserId) { List <Order> orders = new List <Order>(); if (UserId != null) { orders = await db.Order.Include(a => a.Address).Include(u => u.User).Where(x => x.UserId == UserId).ToListAsync(); } else { orders = await db.Order.Include(a => a.Address).Include(u => u.User).ToListAsync(); } OrderSearchView model = new OrderSearchView { Orders = orders, filters = new OrderFilters { SelectFilter = "0" } }; return(View("~/Views/Admin/OrderManagement/OrderManagement.cshtml", model)); }