Adding unit tests, refactoring file access to a service, adding CatalogImageMissingException.
This commit is contained in:
22
src/Infrastructure/FileSystem/LocalFileImageService.cs
Normal file
22
src/Infrastructure/FileSystem/LocalFileImageService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using ApplicationCore.Interfaces;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using System.IO;
|
||||
|
||||
namespace Infrastructure.FileSystem
|
||||
{
|
||||
public class LocalFileImageService : IImageService
|
||||
{
|
||||
private readonly IHostingEnvironment _env;
|
||||
|
||||
public LocalFileImageService(IHostingEnvironment env)
|
||||
{
|
||||
_env = env;
|
||||
}
|
||||
public byte[] GetImageBytesById(int id)
|
||||
{
|
||||
var contentRoot = _env.ContentRootPath + "//Pics";
|
||||
var path = Path.Combine(contentRoot, id + ".png");
|
||||
return File.ReadAllBytes(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,5 +14,8 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.0.2" />
|
||||
<PackageReference Include="StructureMap.Microsoft.DependencyInjection" Version="1.3.0" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ApplicationCore\ApplicationCore.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user