yavsc/Yavsc/Helpers/FileSystemHelpers.cs

25 lines
805 B
C#
Raw Normal View History

2016-05-17 18:22:18 +02:00
using System.IO;
using Microsoft.AspNet.FileProviders;
2016-06-14 03:37:57 +02:00
using Yavsc.Models.Billing;
2016-05-17 18:22:18 +02:00
namespace Yavsc.Helpers
{
public static class FileSystemHelpers {
2016-07-27 11:08:45 +02:00
public static IDirectoryContents GetFileContent(this Estimate estimate, string userFileDir)
2016-05-17 18:22:18 +02:00
{
2016-06-14 03:37:57 +02:00
if (estimate?.Query?.PerformerProfile?.Performer == null)
2016-05-17 18:22:18 +02:00
return null;
2016-09-05 00:24:43 +02:00
var di = new DirectoryInfo(Path.Combine(
2016-05-17 18:22:18 +02:00
userFileDir,
2016-06-14 03:37:57 +02:00
estimate.Query.PerformerProfile.Performer.UserName
2016-05-17 18:22:18 +02:00
));
2016-09-05 00:24:43 +02:00
if (!di.Exists) return null;
var fsp = new PhysicalFileProvider(di.FullName);
2016-05-17 18:22:18 +02:00
return fsp.GetDirectoryContents(
Path.Combine(Constants.UserBillsFilesDir, estimate.Id.ToString())
);
}
}
}