Example #1
0
        public async Task <IActionResult> Remove(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }
            SlideShow existSlideShow = await _iSlideShowManager.GetById(id);

            if (existSlideShow == null)
            {
                NotFound();
            }

            if (existSlideShow.Photo != "slide_show/NoImageFound.jpg")
            {
                var      PhotoName = existSlideShow.Photo;
                var      fullPath  = Path.Combine(_iHostingEnvironment.WebRootPath + "/" + PhotoName);
                FileInfo fi        = new FileInfo(fullPath);
                if (fi != null)
                {
                    System.IO.File.Delete(fullPath);
                    fi.Delete();
                }
            }
            bool remove = await _iSlideShowManager.Remove(existSlideShow);

            if (remove)
            {
                return(RedirectToAction("Index"));
            }

            return(BadRequest());
        }
Example #2
0
        public IActionResult Delete(int?id)
        {
            if (HttpContext.Session.GetString("AdminId") != null)
            {
                SlideShow aSlideShowInfo = _iSlideShowManager.GetById(id);

                bool isDelete = _iSlideShowManager.Remove(aSlideShowInfo);

                if (isDelete)
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    ViewBag.ErrorMessage = "Slide Show delete failed! Try again.";
                }
            }

            return(RedirectToAction("Index", "Login"));
        }