Implemented CatalogImageMissingException in LocalFileImageService
This commit is contained in:
@@ -9,5 +9,10 @@ namespace ApplicationCore.Exceptions
|
|||||||
: base(message, innerException: innerException)
|
: base(message, innerException: innerException)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
public CatalogImageMissingException(Exception innerException)
|
||||||
|
: base("No catalog image found for the provided id.",
|
||||||
|
innerException: innerException)
|
||||||
|
{
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using ApplicationCore.Interfaces;
|
using ApplicationCore.Exceptions;
|
||||||
|
using ApplicationCore.Interfaces;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
@@ -13,10 +14,17 @@ namespace Infrastructure.FileSystem
|
|||||||
_env = env;
|
_env = env;
|
||||||
}
|
}
|
||||||
public byte[] GetImageBytesById(int id)
|
public byte[] GetImageBytesById(int id)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
var contentRoot = _env.ContentRootPath + "//Pics";
|
var contentRoot = _env.ContentRootPath + "//Pics";
|
||||||
var path = Path.Combine(contentRoot, id + ".png");
|
var path = Path.Combine(contentRoot, id + ".png");
|
||||||
return File.ReadAllBytes(path);
|
return File.ReadAllBytes(path);
|
||||||
}
|
}
|
||||||
|
catch (FileNotFoundException ex)
|
||||||
|
{
|
||||||
|
throw new CatalogImageMissingException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user