Esempio n. 1
0
 public ActionResult Delete(int id)
 {
     try
     {
         var obj        = _galleryCategoryReporitory.Find(id);
         var objGallery = _galleryRep.GetAll().ToList();
         foreach (var item in objGallery)
         {
             if (item.CategoryId == id)
             {
                 _galleryRep.Delete(item.ID);
             }
         }
         _galleryCategoryReporitory.Delete(id);
     }
     catch (Exception)
     {
         return(Json(new
         {
             IsSuccess = false,
             Messenger = string.Format("Xóa danh mục thư viện ảnh thất bại")
         }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new
     {
         IsSuccess = true,
         Messenger = "Xóa danh mục thư viện ảnh thành công",
     }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 2
0
        public ActionResult Delete(Guid id)
        {
            if (User.Identity.IsAuthenticated)
            {
                var galleryToRemove = repo.ByID(id);

                if (galleryToRemove.User == User.Identity.Name)
                {
                    if (galleryToRemove.Pictures != null)
                    {
                        foreach (var picture in galleryToRemove.Pictures)
                        {
                            var      filePath = Request.MapPath(picture.Path);
                            FileInfo file     = new FileInfo(filePath);
                            if (file.Exists)
                            {
                                file.Delete();
                            }
                        }
                    }


                    if (repo.Delete(galleryToRemove.id))
                    {
                        return(Content("Gallery deleted!"));
                    }
                    else
                    {
                        return(Content("Couldn't delete gallery"));
                    }
                }
            }
            return(Content("Couldn't delete gallery"));
        }
Esempio n. 3
0
        public ActionResult Delete(int galleryID)
        {
            if (User.Identity.IsAuthenticated)
            {
                var userID = int.Parse(Helpers.GetSid(User.Identity));


                var galleryToRemove = repo.ByID(galleryID);

                if (galleryToRemove.UserID == userID)
                {
                    if (galleryToRemove.Pictures != null)
                    {
                        foreach (var picture in galleryToRemove.Pictures)
                        {
                            var      filePath = Request.MapPath(picture.Path);
                            FileInfo file     = new FileInfo(filePath);
                            if (file.Exists)
                            {
                                file.Delete();
                            }
                        }
                    }


                    repo.Delete(galleryToRemove.id);
                    return(Content("Gallery deleted!"));
                }
            }
            return(Content("Couldn't delete gallery"));
        }
Esempio n. 4
0
        //// TRY WITH THIS LATER
        ////[ValidateAntiForgeryToken]
        public ActionResult Delete(int id, Gallery gallery)
        {
            var currentUserProfile = GetCurrentUserProfile();

            if (currentUserProfile.Id != gallery.UserProfileId)
            {
                return(Unauthorized());
            }
            if (id != gallery.Id)
            {
                return(BadRequest());
            }
            if (gallery == null)
            {
                return(BadRequest());
            }
            if (id == 1)
            {
                return(NotFound());
            }

            try
            {
                _galleryRepository.Delete(id);

                return(Ok(id));
            }
            catch (Exception ex)
            {
                Console.Write("UhOh There was an Exception...", ex);
                return(BadRequest());
            }
        }
Esempio n. 5
0
        public async Task <IActionResult> OnPostAsync(int id)
        {
            Gallery = await _db.Delete(id); //удаляем запись

            if (Gallery.ImagePath != null)
            {
                _filesRepository.DeleteFile(Gallery.ImagePath, "Gallery");                            //удаляем фото
            }
            TempData["SuccessMessage"] = $"Запись \"{Gallery.Name}\" успешно удалена";
            return(RedirectToPage("./Index"));
        }
 public ActionResult Delete(int id)
 {
     try
     {
         var obj = _GalleryRepository.Find(id);
         _GalleryRepository.Delete(id);
     }
     catch (Exception)
     {
         return(Json(new
         {
             IsSuccess = false,
             Messenger = string.Format("Xóa slide ảnh thất bại")
         }, JsonRequestBehavior.AllowGet));
     }
     return(Json(new
     {
         IsSuccess = true,
         Messenger = "Xóa slide ảnh thành công",
     }, JsonRequestBehavior.AllowGet));
 }
Esempio n. 7
0
        public async Task <Result> Delete(GalleryViewModel model)
        {
            try
            {
                return(await _gallery.Delete(GalleryViewModel.Get(model)));
            }
            catch (Exception e)
            {
                await _logger.AddException(e);

                return(Result.Failed);
            }
        }
Esempio n. 8
0
		public JsonResult DeleteGallery(long galleryID, long postgalleryID)
		{
			var model = new GalleryViewModel
			{
				Galleries = _galleryRepository.GetGallerysByPostGallery(postgalleryID)
			};

			try
			{
				_galleryRepository.Delete(galleryID);

				return Json(RedirectToAction("ListGallery", new { postgalleryID = model.PostGalleryID }), JsonRequestBehavior.AllowGet);
			}
			catch (Exception e)
			{
				ModelState.AddModelError(String.Empty, e.Message);
				return Json(model, JsonRequestBehavior.AllowGet);
			}
		}
        public void DeleteGallery(long galleryId, string path)
        {
            var photos = _galleryPhotoRepository.GetAll();

            foreach (var photo in photos)
            {
                if (photo.GalleryId == galleryId)
                {
                    System.IO.File.Delete(path + photo.ImageUrl);
                    var newPhoto = _galleryPhotoRepository.GetById(photo.Id);
                    _galleryPhotoRepository.Delete(newPhoto);
                }
            }


            var gallery = _galleryRepository.GetById(galleryId);

            System.IO.File.Delete(path + gallery.MainImageUrl);


            _galleryRepository.Delete(gallery);
        }
Esempio n. 10
0
 public void DeleteGalleyImage(Gallery image)
 {
     _galleryRepository.Delete(image);
 }
Esempio n. 11
0
 public Gallery Delete(Gallery gallery)
 {
     return(_galleryRepository.Delete(gallery));
 }
Esempio n. 12
0
 public void DeleteGallery(long id)
 {
     galleryRepository.Delete(s => s.Id == id);
 }
Esempio n. 13
0
 public IActionResult DeleteGalleryElement(int id)
 {
     _galleryRepo.Delete(id);
     return(RedirectToAction("ManageGallery"));
 }