示例#1
0
 public ActionResult Index(AlbumViewhelper albumViewhelper)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_MEDIA, Session.getCurrentUser().username, TypeAudit.Album))
     {
         return Redirect("/admin/error/error403");
     }
     saveData(albumViewhelper);
     return View();
 }
示例#2
0
 public List<gov_album> setSearchFilter(List<gov_album> lstAlbum, AlbumViewhelper albumViewhelper)
 {
     Expression<Func<gov_album, bool>> predicate = PredicateBuilder.False<gov_album>();
     if (!String.IsNullOrWhiteSpace(albumViewhelper.KeySearch))
     {
         predicate = predicate.Or(a => a.album_title != null && a.album_title.ToUpper().Contains(albumViewhelper.KeySearch.ToUpper()));
         predicate = predicate.Or(a => a.description != null && a.description.ToUpper().Contains(albumViewhelper.KeySearch.ToUpper()));
         lstAlbum = lstAlbum.Where(predicate.Compile()).ToList();
     }
     return lstAlbum;
 }
示例#3
0
        public AlbumViewhelper saveData(AlbumViewhelper albumViewhelper)
        {
            List<gov_album> lstAlbum = _cnttDB.gov_album.ToList();
            lstAlbum = setSearchFilter(lstAlbum, albumViewhelper);

            int totalCount = lstAlbum.Count;
            albumViewhelper.TotalCount = totalCount;

            if (albumViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                albumViewhelper.TotalPage = totalPage;
                albumViewhelper.Page = pageTransition(albumViewhelper.Direction, albumViewhelper.Page, totalPage);
                albumViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, albumViewhelper.Page);
                albumViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, albumViewhelper.Page, albumViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (albumViewhelper.Page - 1) * take;
                lstAlbum = lstAlbum.OrderByDescending(a => a.order_number).Skip(skip).Take(take).ToList();
                albumViewhelper.LstAlbum = lstAlbum;
            }
            ViewData["albumViewhelper"] = albumViewhelper;
            return albumViewhelper;
        }