public async Task<ActionResult> IndexDiff() { var tableOrder = _productsDb.Where(p => !p.Value.IsPublished).OrderBy(p => p.Value.Title).Select(p => new ServicePublicData() { Id = p.Value.Id.ToString() }).ToList(); var tableOrderVM = new TableOrderViewModel(UIKeysProductDrafts.Index.ProductTableOrder, tableOrder); var titleVM = new TableViewModel(UIKeysProductDrafts.IndexDiff.ProductTitleColumn, page => page.Html.Action("IndexDiff")); var authorVM = new TableViewModel(UIKeysProductDrafts.IndexDiff.ProductAuthorColumn, page => MvcHtmlString.Empty); return ViewModels(tableOrderVM, titleVM, authorVM); }
public async Task<ActionResult> IndexTable(List<ServicePublicData> productTableOrder) { var ids = productTableOrder.Select(p => p.Id).ToList(); var products = _productsDb.Where(p => ids.Contains(p.Value.Id.ToString())).ToList().Select(p => p.Value).ToList(); var titleVM = new TableViewModel(UIKeysProductDrafts.IndexTable.ProductTitleColumn, (page, data) => { var product = products.SingleOrDefault(p => p.Id.ToString() == data.Id); return product != null ? product.Title.ToString() : ""; }); var authorVM = new TableViewModel(UIKeysProductDrafts.IndexTable.ProductAuthorColumn, (page, data) => { var product = products.SingleOrDefault(p => p.Id.ToString() == data.Id); return product != null ? product.Author.ToString() : ""; }); return ViewModels(titleVM, authorVM); }