Пример #1
0
 public SortModel GetSortModel(FilterInfo info)
 {
     var sortInfo = new SortModel();
     sortInfo.Ascending = info.Ascending;
     sortInfo.PreviousTarget = info.Target;
     return sortInfo;
 }
Пример #2
0
 public FilterModel GetFilterModel(FilterInfo info)
 {
     var filter = new FilterModel();
     filter.NameKeyWord = info.NameKeyWord;
     filter.DateKeyWord = info.DateKeyWord;
     filter.AuthorKeyword = info.AuthorKeyword;
     return filter;
 }
Пример #3
0
 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;
 }
Пример #4
0
 public List<Document> GetSortedDocumentsByFilter(FilterInfo info)
 {
     using (ISession session = NHibernateHelper.OpenSession())
     {
         ICriteria criteria = session.CreateCriteria<Document>();
         criteria.Add(Restrictions.Like("Name", info.NameKeyWord, MatchMode.Anywhere));
         if (info.DateKeyWord != null)
         {
             criteria.Add(Restrictions.Eq("Date", info.DateKeyWord));
         }
         criteria.Add(Restrictions.Like("Author", info.AuthorKeyword, MatchMode.Anywhere));
         if (!string.IsNullOrEmpty(info.Target) && info.Ascending.HasValue)
         {
             criteria.AddOrder((info.Ascending.Value) ? Order.Asc(info.Target) : Order.Desc(info.Target));
         }
         return criteria.List<Document>().ToList();
     }
 }