示例#1
0
        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"));
        }
示例#3
0
        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"));
        }