public bool Delete(int id)
 {
     using (var context = _dbContextFactory.CreateConnection())
     {
         Album_Gallery Images = context.Album_Gallery.Where(x => x.Galleryid == id).FirstOrDefault();
         Images.Status = false;
         context.SaveChanges();
         return(true);
     }
 }
Beispiel #2
0
        public ActionResult Gallery(GalleryModel Gallery, IEnumerable <HttpPostedFileBase> Images, HttpPostedFileBase Videos)
        {
            if (ModelState.IsValid)
            {
                if (Gallery.selectionType == 2)
                {
                    var fileName = Path.GetFileName(Videos.FileName);
                    var path     = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                    Videos.SaveAs(path);
                    var           FilePath = "/UserProfilePictures/" + fileName;
                    Album_Gallery Album    = new Album_Gallery()
                    {
                        CreateOn    = DateTime.Now,
                        AlbumName   = Gallery.Title,
                        GalleryDate = Gallery.GalleryDate,
                        Description = Gallery.Description,
                        AlbumType   = "Videos",
                        Status      = true
                    };
                    Album_Gallery        gallery       = AlbumGalleryService.Create(Album);
                    Album_Gallery_Images ImagesGallery = new Album_Gallery_Images()
                    {
                        Image     = FilePath,
                        AlbumId   = gallery.Galleryid,
                        CreatedOn = DateTime.Now,
                        AlbumType = "Videos",
                        Status    = true
                    };

                    AlbumGalleryService.CreateImagesAndVideos(ImagesGallery);
                }
                else if (Gallery.selectionType == 1)
                {
                    Album_Gallery Album = new Album_Gallery()
                    {
                        CreateOn    = DateTime.Now,
                        AlbumName   = Gallery.Title,
                        GalleryDate = Gallery.GalleryDate,
                        Description = Gallery.Description,
                        AlbumType   = "Images",
                        Status      = true
                    };
                    Album_Gallery gallery = AlbumGalleryService.Create(Album);

                    foreach (var GalleryImages in Images)
                    {
                        var fileName = Path.GetFileName(GalleryImages.FileName);
                        var path     = Path.Combine(Server.MapPath("~/UserProfilePictures/" + fileName));
                        GalleryImages.SaveAs(path);
                        var FilePath = "/UserProfilePictures/" + fileName;

                        Album_Gallery_Images ImagesGallery = new Album_Gallery_Images()
                        {
                            Image     = FilePath,
                            AlbumId   = gallery.Galleryid,
                            CreatedOn = DateTime.Now,
                            AlbumType = "Images",
                            Status    = true
                        };

                        AlbumGalleryService.CreateImagesAndVideos(ImagesGallery);
                    }
                }
                TempData["Message"] = "Album Saved successfully..";
                return(RedirectToAction("Gallery", "Gallery", new { area = "Admin" }));
            }
            return(View());
        }