Beispiel #1
0
        public async Task <IActionResult> OnPostAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SlidNew_produc = await _context.slidNew_Producs.FindAsync(id);

            if (SlidNew_produc != null)
            {
                _context.slidNew_Producs.Remove(SlidNew_produc);
                await _context.SaveChangesAsync();
            }


            string filePath = Path.Combine(Directory.GetCurrentDirectory(),
                                           "wwwroot",
                                           "Image",
                                           SlidNew_produc.NewBookName + ".jpg");

            if (System.IO.File.Exists(filePath))
            {
                System.IO.File.Delete(filePath);
            }



            return(RedirectToPage("./Index"));
        }
Beispiel #2
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            SlidNew_produc = await _context.slidNew_Producs.FirstOrDefaultAsync(m => m.Id == id);

            if (SlidNew_produc == null)
            {
                return(NotFound());
            }
            return(Page());
        }