public ActionResult OnGetDelete(int?id) { if (id != null) { var data = (from Order in _context.Order where Order.OrderId == id select Order).SingleOrDefault(); _context.Remove(data); _context.SaveChanges(); } return(RedirectToPage("Index")); }
public ActionResult OnGetDelete(int?id) { if (id != null) { var data = (from clothings in _context.Clothing where clothings.Id == id select clothings).SingleOrDefault(); _context.Remove(data); _context.SaveChanges(); } return(RedirectToPage("Index")); }
public ActionResult OnGetDelete(int?id) { if (id != null) { var data = (from clothings in _context.Clothing where clothings.Id == id select clothings).SingleOrDefault(); //Kollar om bilden finns på datorn. var filePath = "./wwwroot" + data.ImageUrl; if (System.IO.File.Exists(filePath)) { System.IO.File.Delete(filePath); } _context.Remove(data); _context.SaveChanges(); } return(RedirectToPage("Index")); }