public MaintenanceModel() { DeleteGuests = new DeleteGuestsModel(); DeleteAbandonedCarts = new DeleteAbandonedCartsModel(); DeleteExportedFiles = new DeleteExportedFilesModel(); BackupFileSearchModel = new BackupFileSearchModel(); }
/// <summary> /// Prepare paged backup file list model /// </summary> /// <param name="searchModel">Backup file search model</param> /// <returns>Backup file list model</returns> public virtual BackupFileListModel PrepareBackupFileListModel(BackupFileSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get backup files var backupFiles = _maintenanceService.GetAllBackupFiles().ToList(); //prepare list model var model = new BackupFileListModel { Data = backupFiles.PaginationByRequestModel(searchModel).Select(file => { //fill in model values from the entity var backupFileModel = new BackupFileModel { Name = _fileProvider.GetFileName(file) }; //fill in additional values (not existing in the entity) backupFileModel.Length = $"{_fileProvider.FileLength(file) / 1024f / 1024f:F2} Mb"; backupFileModel.Link = $"{_webHelper.GetStoreLocation(false)}db_backups/{backupFileModel.Name}"; return(backupFileModel); }), Total = backupFiles.Count }; return(model); }
/// <summary> /// Prepare paged backup file list model /// </summary> /// <param name="searchModel">Backup file search model</param> /// <returns>Backup file list model</returns> public virtual Task <BackupFileListModel> PrepareBackupFileListModelAsync(BackupFileSearchModel searchModel) { if (searchModel == null) { throw new ArgumentNullException(nameof(searchModel)); } //get backup files var backupFiles = _maintenanceService.GetAllBackupFiles().ToPagedList(searchModel); //prepare list model var model = new BackupFileListModel().PrepareToGrid(searchModel, backupFiles, () => { return(backupFiles.Select(file => new BackupFileModel { Name = _fileProvider.GetFileName(file), //fill in additional values (not existing in the entity) Length = $"{_fileProvider.FileLength(file) / 1024f / 1024f:F2} Mb", Link = $"{(_webHelper.GetStoreLocation(false))}db_backups/{_fileProvider.GetFileName(file)}" })); }); return(Task.FromResult(model)); }
/// <summary> /// Prepare backup file search model /// </summary> /// <param name="searchModel">Backup file search model</param> /// <returns>Backup file search model</returns> protected virtual BackupFileSearchModel PrepareBackupFileSearchModel(BackupFileSearchModel searchModel) { if (searchModel == null) throw new ArgumentNullException(nameof(searchModel)); //prepare page parameters searchModel.SetGridPageSize(); return searchModel; }
public virtual IActionResult BackupFiles(BackupFileSearchModel searchModel) { if (!_permissionService.Authorize(StandardPermissionProvider.ManageMaintenance)) { return(AccessDeniedKendoGridJson()); } //prepare model var model = _commonModelFactory.PrepareBackupFileListModel(searchModel); return(Json(model)); }
/// <returns>A task that represents the asynchronous operation</returns> public virtual async Task <IActionResult> BackupFiles(BackupFileSearchModel searchModel) { if (!await _permissionService.AuthorizeAsync(StandardPermissionProvider.ManageMaintenance)) { return(await AccessDeniedDataTablesJson()); } //prepare model var model = await _commonModelFactory.PrepareBackupFileListModelAsync(searchModel); return(Json(model)); }