예제 #1
0
        public IActionResult ShowPhotosAlbum(int?id)
        {
            try
            {
                PhotosAlbumViewModel vm = new PhotosAlbumViewModel();
                vm.Photo = _db.Photoes
                           .Where(p => p.Album.Id == id)
                           .Include(a => a.Album)
                           .ToList();
                var i = vm.Photo;
                vm.CommentLst = _db.Comments.ToList();
                vm.IdRoute    = id;

                CommentViewModel model = new CommentViewModel();
                string           imgUrl;
                _session.CaptchaCodeInShowPhotosAlbum = model.GenerateCaptchaCode(out imgUrl);
                ViewBag.CaptchaImageInShowPhotosAlbum = imgUrl;

                return(View(vm));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(HomeController.Error), "Home"));
            }
        }
예제 #2
0
        public IActionResult ShowPhotosComment(int?id)
        {
            try
            {
                PhotosCommentViewModel vm = new PhotosCommentViewModel();
                vm.PhotoId = _db.Photoes.FirstOrDefault(x => x.Id == id);

                // var i = vm.Photo;

                vm.CommentLst = _db.Comments
                                .Where(p => p.PhotoId == vm.PhotoId.Id && p.status == true)

                                .ToList();
                vm.IdRoute = id;

                CommentViewModel model = new CommentViewModel();
                string           imgUrl;
                _session.CaptchaCodeInPhotosComment = model.GenerateCaptchaCode(out imgUrl);
                ViewBag.CaptchaImageInPhotosComment = imgUrl;

                return(View(vm));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(HomeController.Error), "Home"));
            }
        }