コード例 #1
0
 public ActionResult Index(GalleryViewhelper galleryViewhelper)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_MEDIA, Session.getCurrentUser().username, TypeAudit.Gallery))
     {
         return Redirect("/admin/error/error403");
     }
     saveData(galleryViewhelper);
     return View();
 }
コード例 #2
0
 public List<gov_gallery> setSearchFilter(List<gov_gallery> lstGallery, GalleryViewhelper galleryViewhelper)
 {
     Expression<Func<gov_gallery, bool>> predicate = PredicateBuilder.False<gov_gallery>();
     if (!String.IsNullOrEmpty(galleryViewhelper.KeySearch))
     {
         predicate = predicate.Or(d => d.title != null && d.title.ToUpper().Contains(galleryViewhelper.KeySearch.ToUpper()));
         predicate = predicate.Or(d => d.update_username != null && d.update_username.ToUpper().Contains(galleryViewhelper.KeySearch.ToUpper()));
         lstGallery = lstGallery.Where(predicate.Compile()).ToList();
     }
     return lstGallery;
 }
コード例 #3
0
        public void saveListImages(GalleryViewhelper galleryViewhelper)
        {
            List<gov_album_gallery> lstGallery = _cnttDB.gov_album_gallery.Where(g => g.album_id == galleryViewhelper.AlbumId).ToList();
            int totalCount = lstGallery.Count;
            galleryViewhelper.TotalCount = totalCount;

            if (galleryViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                galleryViewhelper.TotalPage = totalPage;
                galleryViewhelper.Page = pageTransition(galleryViewhelper.Direction, galleryViewhelper.Page, totalPage);
                galleryViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page);
                galleryViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page, galleryViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (galleryViewhelper.Page - 1) * take;
                lstGallery = lstGallery.OrderByDescending(s => s.update_datetime).Skip(skip).Take(take).ToList();
                galleryViewhelper.LstAlbumGallery = lstGallery;
            }
            ViewData["galleryViewhelper"] = galleryViewhelper;
        }
コード例 #4
0
        public GalleryViewhelper saveData(GalleryViewhelper galleryViewhelper)
        {
            List<gov_gallery> lstGallery = _cnttDB.gov_gallery.ToList();
            lstGallery = setSearchFilter(lstGallery, galleryViewhelper);

            int totalCount = lstGallery.Count;
            galleryViewhelper.TotalCount = totalCount;

            if (galleryViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                galleryViewhelper.TotalPage = totalPage;
                galleryViewhelper.Page = pageTransition(galleryViewhelper.Direction, galleryViewhelper.Page, totalPage);
                galleryViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page);
                galleryViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page, galleryViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (galleryViewhelper.Page - 1) * take;
                lstGallery = lstGallery.OrderByDescending(g => g.entry_datetime).Skip(skip).Take(take).ToList();
                galleryViewhelper.LstGallery = lstGallery;
            }
            ViewData["galleryViewhelper"] = galleryViewhelper;
            return galleryViewhelper;
        }
コード例 #5
0
 public void setSearchFilter1(GalleryServices galleryServices, GalleryViewhelper galleryViewhelper)
 {
     if (galleryViewhelper.Filter)
         galleryServices.IdNotInAlbum = "TRUE";
 }
コード例 #6
0
        public void saveAddGallery(GalleryViewhelper galleryViewhelper)
        {
            var lstGallery = (from g in _cnttDB.gov_gallery
                        where !_cnttDB.gov_album_gallery.Any(p => p.gallery_id == g.id && p.album_id == galleryViewhelper.AlbumId)
                        select g).ToList();
            int totalCount = lstGallery.Count;
            galleryViewhelper.TotalCount = totalCount;
            //setSearchFilter1(galleryServices, galleryViewhelper);

            if (galleryViewhelper.TotalCount > 0)
            {
                int totalPage = pageCalculation(totalCount, Constant.limit);
                galleryViewhelper.TotalPage = totalPage;
                galleryViewhelper.Page = pageTransition(galleryViewhelper.Direction, galleryViewhelper.Page, totalPage);
                galleryViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page);
                galleryViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, galleryViewhelper.Page, galleryViewhelper.FirstPage);
                int take = Constant.limit;
                int skip = (galleryViewhelper.Page - 1) * take;
                lstGallery = lstGallery.OrderByDescending(s => s.entry_datetime).Skip(skip).Take(take).ToList();
                galleryViewhelper.LstGallery = lstGallery;
            }
            ViewData["galleryViewhelper"] = galleryViewhelper;
        }
コード例 #7
0
 public ActionResult DeleteImages(GalleryViewhelper galleryViewhelper)
 {
     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");
     }
     String content = "";
     foreach (int id in galleryViewhelper.CheckId)
     {
         gov_album_gallery item = _cnttDB.gov_album_gallery.Single(s => s.album_id == galleryViewhelper.AlbumId && s.gallery_id == id);
         _cnttDB.gov_album_gallery.Remove(item);
         int rs = _cnttDB.SaveChanges();
         if (rs > 0)
         {
             content += Constant.XOA_IN(Constant.ITEM_HINHANH, Constant.ID, id.ToString(), Constant.ITEM_ALBUM, Constant.ID, galleryViewhelper.AlbumId.ToString());
             content += ".<br/>";
         }
     }
     if (!content.Equals(""))
     {
         insertHistory(AccessType.XoaAnhKhoiAlbum, content);
         TempData["message"] = Constant.DELETE_SUCCESSFULL;
     }
     return Redirect("ListImages?albumid=" + galleryViewhelper.AlbumId.ToString());
 }
コード例 #8
0
 public ActionResult ListImages(int albumId) {
     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");
     }
     GalleryViewhelper galleryViewhelper = new GalleryViewhelper();
     galleryViewhelper.AlbumId = albumId;
     saveListImages(galleryViewhelper);
     return View();
 }
コード例 #9
0
 public ActionResult SaveAddImages(GalleryViewhelper galleryViewhelper)
 {
     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");
     }
     String content = "";
     foreach (int galleryId in galleryViewhelper.CheckId)
     {
         gov_album_gallery item = new gov_album_gallery();
         item.album_id = galleryViewhelper.AlbumId;
         item.update_username = Session.getCurrentUser().username;
         item.update_datetime = DateTime.Now;
         item.gallery_id = galleryId;
         _cnttDB.gov_album_gallery.Add(item);
         int rs = _cnttDB.SaveChanges();
         if (rs > 0) {
             content += Constant.THEM_IN(Constant.ITEM_HINHANH, Constant.ID, galleryId.ToString(), Constant.ITEM_ALBUM, Constant.ID, galleryViewhelper.AlbumId.ToString());
             content += ".<br/>";
         }
     }
     if (!content.Equals(""))
     {
         insertHistory(AccessType.themAnhVaoAlbum, content);
         TempData["message"] = Constant.REGIST_SUCCESSFULL;
     }
     return Redirect("listimages?albumId=" + galleryViewhelper.AlbumId.ToString());
 }