using Microsoft.AspNetCore.Mvc; using StorageServer.IO; using StorageServer.Models; using StorageServer.Models.Request; using StorageServer.Models.Response; namespace StorageServer.Controllers; public class FileListController : Controller { private readonly DatabaseFactory database; public FileListController(DatabaseFactory database) { this.database = database; } public IActionResult Read(FileListReadModel model) { if (!ModelState.IsValid) { return BadRequest(); } if (model.Page < 0) { return BadRequest(); } try { IEnumerable fileModels = this.database.ReadAll(); int readCount = 100; IEnumerable seekedModels = fileModels.Skip(readCount * model.Page).Take(readCount); List fileLists = new List(); foreach (FileModel fileModel in seekedModels) { fileLists.Add(new FileListResponseModel(fileModel)); } return Json(fileLists); } catch (Exception) { return Problem(); } } }