1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| public ActionResult DeletePreins(string id)
{
try
{
Models.J2VEntities entity = new Models.J2VEntities();
Models.preinscrit model = (from p in entity.preinscrit
where p.Idag == id
select p).SingleOrDefault();
// Suprime l'image
var destinationFolder = Server.MapPath("/Content/Agpic");
var path = Path.Combine(destinationFolder, model.Idag + ".jpg");
System.IO.File.Delete(path);
//Sauvgarde ds la BD
entity.preinscrit.DeleteObject(model);
entity.SaveChanges();
return Succes Message;
}
catch(Exception)
{
return Failor Message;
}
} |
Partager