Petit Cleanup pour l'ImageController.
This commit is contained in:
@@ -32,7 +32,7 @@ public class ProductController : ControllerBase {
|
||||
private readonly IWebHostEnvironment _hostEnvironment;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Ctor
|
||||
public ProductController(ILogger<ProductController> logger, InventoryContext context, DatabaseCacheService cache, IWebHostEnvironment hostEnvironment) {
|
||||
_logger = logger;
|
||||
@@ -42,7 +42,7 @@ public class ProductController : ControllerBase {
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region API Methods
|
||||
[EnableCors("_myAllowSpecificOrigins"), HttpGet(Name = "Product"), AllowAnonymous]
|
||||
public ActionResult<ProductViewModel> Get(int id) {
|
||||
@@ -107,7 +107,7 @@ public class ProductController : ControllerBase {
|
||||
|
||||
#endregion
|
||||
|
||||
#region UtilityMethods
|
||||
#region Utility Methods
|
||||
private async Task<string> SaveImage(IFormFile imageFile) {
|
||||
string imageName = new String(Path.GetFileNameWithoutExtension(imageFile.FileName).Take(10).ToArray()).Replace(' ', '-');
|
||||
imageName = imageName + DateTime.Now.ToString("yymmssfff") + Path.GetExtension(imageFile.FileName);
|
||||
@@ -121,7 +121,6 @@ public class ProductController : ControllerBase {
|
||||
}
|
||||
|
||||
private void SaveImageThumbnail(FileStream stream, string imageName) {
|
||||
|
||||
try {
|
||||
const float maxSize = 200f;
|
||||
Image image = Image.FromStream(stream);
|
||||
@@ -136,8 +135,6 @@ public class ProductController : ControllerBase {
|
||||
catch (Exception ex) {
|
||||
_logger.LogError(8, ex.Message);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
Reference in New Issue
Block a user