public SortModel GetSortModel(FilterInfo info) { var sortInfo = new SortModel(); sortInfo.Ascending = info.Ascending; sortInfo.PreviousTarget = info.Target; return sortInfo; }
public FilterInfo GetFilterInfo(FilterModel filter, SortModel sortInfo) { var info = new FilterInfo(); info.NameKeyWord = filter.NameKeyWord; info.DateKeyWord = filter.DateKeyWord; info.AuthorKeyword = filter.AuthorKeyword; info.Ascending = sortInfo.Ascending; info.Target = sortInfo.CurrentTarget; return info; }
public ActionResult GetSortedDocumentsByFilter(FilterModel filter, SortModel sortInfo) { var documentModels = new DocumentMainViewModel(); if (sortInfo.IsSet()) { if (sortInfo.PreviousTarget == null || sortInfo.TargetIsChange()) { sortInfo.Ascending = true; } else { sortInfo.Ascending = !sortInfo.Ascending; } } var filterInfo = mapper.GetFilterInfo(filter, sortInfo); var filteredDocuments = docService.GetSortedDocumentsByFilter(filterInfo); filteredDocuments.ForEach(doc => documentModels.Documents.Add(mapper.GetDocumentViewModel(doc))); documentModels.Filter = mapper.GetFilterModel(filterInfo); documentModels.SortParam = mapper.GetSortModel(filterInfo); return View("Index", documentModels); }