Created
September 16, 2018 13:48
-
-
Save JordiCorbilla/ad13dbb53429e96c055deacf8ee485f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Authorize(Policy = "Administrator")] | |
public IActionResult ListFiles(string date) | |
{ | |
var model = new FilesViewModel(); | |
DateTime day; | |
if (!string.IsNullOrEmpty(date)) | |
{ | |
day = DateTime.ParseExact(date, "yyyyMMdd", CultureInfo.InvariantCulture); | |
} | |
else | |
{ | |
day = DateTime.UtcNow; | |
} | |
string todayDate = day.ToString("yyyyMMdd"); | |
string yesterday = day.AddDays(-1).ToString("yyyyMMdd"); | |
string tomorrow = day.AddDays(1).ToString("yyyyMMdd"); | |
model.Today = todayDate; | |
model.TodayFormat = day.ToString("dd-MMM-yyyy"); | |
model.Yesterday = yesterday; | |
model.Tomorrow = tomorrow; | |
foreach (var item in _fileProvider.GetDirectoryContents(todayDate)) | |
{ | |
FileInfo f = new FileInfo(item.PhysicalPath); | |
model.Files.Add(new FileDetails { Name = item.Name, FullPath = item.PhysicalPath, CreationTime = f.CreationTime, Size = f.Length }); | |
} | |
return View(model); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment