mirror of
https://github.com/claunia/marechai.git
synced 2025-12-16 19:14:25 +00:00
Remove files when machine photo is removed.
This commit is contained in:
@@ -452,6 +452,14 @@ namespace cicm_web.Areas.Admin.Controllers
|
||||
MachinePhoto machinePhoto = await _context.MachinePhotos.FindAsync(id);
|
||||
_context.MachinePhotos.Remove(machinePhoto);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
foreach(string format in new[] {"jpg", "webp"})
|
||||
{
|
||||
foreach(int multiplier in new[] {1, 2, 3})
|
||||
System.IO.File.Delete(Path.Combine(hostingEnvironment.WebRootPath, "assets/photos/machines/thumbs",
|
||||
format, $"{multiplier}x", id + $".{format}"));
|
||||
}
|
||||
|
||||
return RedirectToAction(nameof(Index));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user