0
0

Delete thumb file

This commit is contained in:
Sergey Chebotar 2023-06-05 07:15:14 +03:00
parent afb8a23588
commit 0f5cbb4d87

View File

@ -96,6 +96,13 @@ namespace MyDarling.Controllers
figureFile.Delete(); figureFile.Delete();
} }
string thumbFilePath = $"/Content/{product.Id}/{figure.Id}_thumb.jpg";
FileInfo thumbFile = new FileInfo(environment.WebRootPath + thumbFilePath);
if (thumbFile.Exists)
{
thumbFile.Delete();
}
context.Figures.Remove(figure); context.Figures.Remove(figure);
await context.SaveChangesAsync(); await context.SaveChangesAsync();
return RedirectToAction("Details", "Products", new { Id = product?.Id }); return RedirectToAction("Details", "Products", new { Id = product?.Id });