В настоящее время у меня есть страница, которая выглядит следующим образом.
, и у меня есть ссылка действия на моей домашней странице, которая выглядит следующим образом
<li>@Html.ActionLink("Off Site Inventory Order (OSI)", "Index", "SalesOrders", new { type = "OSI"}, null) </li>
Эта ссылка, однако, не делает то, что я хочу, поэтому я надеялся получить помощь. Когда я нажимаю этот щелчок на главной странице, я хочу, чтобы он направлял меня на ту страницу, которую я показывал вам выше, однако я хочу, чтобы она фильтровалась по типу заказа 'OSI', чтобы он автоматически выглядел следующим образом
[
, где вместо этого она фильтрует страницу по порядку OSI.
Вот мой метод salesOrderController GET
public ActionResult Index(int? wholesalerID)
{
int perpage = 50;
ViewBag.ErrorMessage = "";
if (TempData["ErrorMessage"] != null)
ViewBag.ErrorMessage = TempData["ErrorMessage"];
var salesOrders = db.SalesOrders
.Include(s => s.Customers)
.Include(s => s.Partners)
.Include(s => s.Wholesaler)
.Include(s => s.RnD)
.Include(s => s.ECommerce)
.Include(s => s.Direct)
.Include(s => s.Marketing)
.Where(x => x.deleted.Equals(false))
.OrderBy(x => x.SalesOrderStatus).ThenByDescending(x => x.ID);
ViewBag.CanSeeCost = false;
if (IGT.canAccess(IGT.userId, AccessRestrictions.ModifySalesOrder, false))
{
ViewBag.CanSeeCost = true;
var total = salesOrders.Where(s => ((s.SalesOrderStatus == SOStatus.Released) || (s.SalesOrderStatus == SOStatus.Shipped) || s.SalesOrderStatus == SOStatus.Close) && !s.deleted);
ViewBag.TotalRetail = total.Sum(x => x.totalRetail);
ViewBag.TotalShipping = total.Sum(x => x.totalShipped);
ViewBag.TotalRemaining = ViewBag.TotalRetail - ViewBag.TotalShipping;
if (total.FirstOrDefault(x => x.NoCharge) != null)
{
ViewBag.TotalRetailNoCharge = total.Where(x => x.NoCharge).Sum(x => x.totalRetail);
ViewBag.TotalShippingNoCharge = total.Where(x => x.NoCharge).Sum(x => x.totalShipped);
ViewBag.TotalRemainingNoCharge = ViewBag.TotalRetailNoCharge - ViewBag.TotalShippingNoCharge;
}
else
{
ViewBag.TotalRetailNoCharge = 0;
ViewBag.TotalShippingNoCharge = 0;
ViewBag.TotalRemainingNoCharge = 0;
}
}
ViewBag.Customers = new SelectList(db.SalesOrders.Where(x => x.customerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.customerID, x.CustomerName }).Distinct(), "customerID", "CustomerName");
ViewBag.Retailers = new SelectList(db.SalesOrders.Where(x => x.partnerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.partnerID, x.CustomerName }).Distinct(), "partnerID", "CustomerName");
ViewBag.Dealers = new SelectList(db.SalesOrders.Where(x => x.wholesalerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.wholesalerID, x.CustomerName }).Distinct(), "wholesalerID", "CustomerName");
ViewBag.RnDs = new SelectList(db.SalesOrders.Where(x => x.rndID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.rndID, x.CustomerName }).Distinct(), "rndID", "CustomerName");
ViewBag.ECommerces = new SelectList(db.SalesOrders.Where(x => x.eID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.eID, x.CustomerName }).Distinct(), "eID", "CustomerName");
ViewBag.Directs = new SelectList(db.SalesOrders.Where(x => x.directID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.directID, x.CustomerName }).Distinct(), "directID", "CustomerName");
ViewBag.Marketings = new SelectList(db.SalesOrders.Where(x => x.marketingID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.marketingID, x.CustomerName }).Distinct(), "marketingID", "CustomerName");
ViewBag.PO = new SelectList(db.SalesOrders.Where(x => !x.deleted).Where(x => x.CustomerPONumber != null), "CustomerPONumber", "CustomerPONumber");
ViewBag.orderby = "true";
ViewBag.sortOrder = "status";
ViewBag.wholesalerID = wholesalerID;
ViewBag.page = 1;
ViewBag.totalPages = (int)Math.Ceiling((float)salesOrders.Count() / perpage);
return View(salesOrders.Take(perpage).ToList());
}
Но я не уверен, как сделать сообщение, у меня есть метод фильтра, который работает для всех фильтров на экране, но не уверен, что я просто манипулируйте этим, или создайте метод индексной публикации или что
В ответ на полученный ответ я сделал его похожим на мой метод фильтра, так что теперь он выглядит так
if (type == "OSI")
{
ordertype = 3; // OSI Order Id
ViewBag.Customers = new SelectList(db.SalesOrders.Where(x => x.customerID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.customerID, x.CustomerName }).Distinct(), "customerID", "CustomerName");
ViewBag.Retailers = new SelectList(db.SalesOrders.Where(x => x.partnerID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.partnerID, x.CustomerName }).Distinct(), "partnerID", "CustomerName");
ViewBag.Dealers = new SelectList(db.SalesOrders.Where(x => x.wholesalerID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.wholesalerID, x.CustomerName }).Distinct(), "wholesalerID", "CustomerName");
ViewBag.RnDs = new SelectList(db.SalesOrders.Where(x => x.rndID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.rndID, x.CustomerName }).Distinct(), "rndID", "CustomerName");
ViewBag.ECommerces = new SelectList(db.SalesOrders.Where(x => x.eID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.eID, x.CustomerName }).Distinct(), "eID", "CustomerName");
ViewBag.Directs = new SelectList(db.SalesOrders.Where(x => x.directID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.directID, x.CustomerName }).Distinct(), "directID", "CustomerName");
ViewBag.Marketings = new SelectList(db.SalesOrders.Where(x => x.marketingID != null && !x.deleted && x.OrderType == (SOType)ordertype).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.marketingID, x.CustomerName }).Distinct(), "marketingID", "CustomerName");
}
else
{
ViewBag.Customers = new SelectList(db.SalesOrders.Where(x => x.customerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.customerID, x.CustomerName }).Distinct(), "customerID", "CustomerName");
ViewBag.Retailers = new SelectList(db.SalesOrders.Where(x => x.partnerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.partnerID, x.CustomerName }).Distinct(), "partnerID", "CustomerName");
ViewBag.Dealers = new SelectList(db.SalesOrders.Where(x => x.wholesalerID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.wholesalerID, x.CustomerName }).Distinct(), "wholesalerID", "CustomerName");
ViewBag.RnDs = new SelectList(db.SalesOrders.Where(x => x.rndID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.rndID, x.CustomerName }).Distinct(), "rndID", "CustomerName");
ViewBag.ECommerces = new SelectList(db.SalesOrders.Where(x => x.eID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.eID, x.CustomerName }).Distinct(), "eID", "CustomerName");
ViewBag.Directs = new SelectList(db.SalesOrders.Where(x => x.directID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.directID, x.CustomerName }).Distinct(), "directID", "CustomerName");
ViewBag.Marketings = new SelectList(db.SalesOrders.Where(x => x.marketingID != null && !x.deleted).ToList().OrderBy(x => x.CustomerName).Select(x => new { x.marketingID, x.CustomerName }).Distinct(), "marketingID", "CustomerName");
ViewBag.PO = new SelectList(db.SalesOrders.Where(x => !x.deleted).Where(x => x.CustomerPONumber != null), "CustomerPONumber", "CustomerPONumber");
}
ViewBag.orderby = "true";
ViewBag.sortOrder = "status";
ViewBag.wholesalerID = wholesalerID;
ViewBag.type = type;
ViewBag.page = 1;
ViewBag.totalPages = (int)Math.Ceiling((float)salesOrders.Count() / perpage);
return View(salesOrders.Take(perpage).ToList());
}