public BackupDatabaseViewhelper saveData(BackupDatabaseViewhelper backupDatabaseViewhelper) { //Get file in base dir var fileDir = System.AppDomain.CurrentDomain.BaseDirectory + Constant.BACKUP_FOLDER_PATH; DirectoryInfo directory = new DirectoryInfo(fileDir); if (!System.IO.Directory.Exists(fileDir)) System.IO.Directory.CreateDirectory(fileDir); List<FileInfo> lstBackupDatabase= directory.GetFiles().ToList(); //lstUser = setSearchFilter(lstUser, backupDatabaseViewhelper); int totalCount = lstBackupDatabase.Count; backupDatabaseViewhelper.TotalCount = totalCount; if (backupDatabaseViewhelper.TotalCount > 0) { int totalPage = pageCalculation(totalCount, Constant.limit); backupDatabaseViewhelper.TotalPage = totalPage; backupDatabaseViewhelper.Page = pageTransition(backupDatabaseViewhelper.Direction, backupDatabaseViewhelper.Page, totalPage); backupDatabaseViewhelper.FirstPage = fistPageCalculation(Constant.maxPageLine, totalPage, backupDatabaseViewhelper.Page); backupDatabaseViewhelper.LastPage = lastPageCalculation(Constant.maxPageLine, totalPage, backupDatabaseViewhelper.Page, backupDatabaseViewhelper.FirstPage); int take = Constant.limit; int skip = (backupDatabaseViewhelper.Page - 1) * take; backupDatabaseViewhelper.LstBackupDatabase = lstBackupDatabase.OrderByDescending(f => f.Name).Skip(skip).Take(take).ToList(); } ViewData["backupDatabaseViewhelper"] = backupDatabaseViewhelper; return backupDatabaseViewhelper; }
public ActionResult Index(BackupDatabaseViewhelper backupDatabaseViewhelper) { if (Session.getCurrentUser() == null) return Redirect("/admin/account/logon"); if (!SercurityServices.HasPermission((int)TypeModule.MODULE_HETHONG, Session.getCurrentUser().username, TypeAudit.BackupDatabase)) { return Redirect("/admin/error/error403"); } saveData(backupDatabaseViewhelper); return View(); }