I have gallery in my project. I save images on the hard drive but tags, descriptions, etc. I save to the database. Working with the database and data validation going through the service layer. Since the user has remove the image, the files will be removed from the hard drive and the record will be removed from database.
//Action
public ActionResult Delete (int id)
(
var entity = ServiceLayer.Entities.Get (id);
System.IO.File.Delete (entity.FileName); //Might it be also be put to the service layer?
ServiceLayer.Entities.Delete (entit);
return RedirectToAction ( "Index");
)
Is it better to put the code for deleting files in the service level or controller?