Exemplo n.º 1
0
        public ActionResult IndexAlbum(string id)
        {
            List <Comment>          comments = commentRepository.GetAllComentsByAlbumID(id);
            List <CommentViewModel> model    = new List <CommentViewModel>();

            comments.ForEach(x => model.Add(CommentMapper.MapCommentViewModel(x)));

            return(View("Index", model));
        }
Exemplo n.º 2
0
        public ActionResult AlbumComments(string id)
        {
            List <Comment>          comments = commentRepository.GetAllComentsByAlbumID(id).OrderBy(x => x.Date).ToList();
            List <CommentViewModel> model    = new List <CommentViewModel>();

            comments.ForEach(x => model.Add(CommentMapper.MapCommentViewModel(x)));



            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 3
0
        public ActionResult Delete(CommentViewModel model)
        {
            Comment comment = commentRepository.GetCommentByID(model.id);

            model = CommentMapper.MapCommentViewModel(comment);


            var photoid = comment.Photo != null ? comment.Photo.UserID : Guid.Empty;
            var albumid = comment.Album != null ? comment.Album.UserID : Guid.Empty;

            if (photoid == userID || albumid == userID)
            {
                return(View(model));
            }
            return(View());
        }
Exemplo n.º 4
0
        public ActionResult AlbumComments(string id, string comment)
        {
            Guid userID = UserHelper.GetLogedInUser(userRepository).Id;

            var comm = new Comment {
                AlbumID = new Guid(id),
                Date    = DateTime.Now,
                Content = comment,
                Id      = Guid.NewGuid(),
                UserID  = userID
            };

            commentRepository.AddComment(comm);

            List <Comment>          comments = commentRepository.GetAllComentsByAlbumID(id.ToString()).OrderBy(x => x.Date).ToList();
            List <CommentViewModel> model    = new List <CommentViewModel>();

            comments.ForEach(x => model.Add(CommentMapper.MapCommentViewModel(x)));



            return(Json(model));
        }
Exemplo n.º 5
0
        public ActionResult Delete(CommentViewModel model, FormCollection collection)
        {
            var comment = commentRepository.GetCommentByID(model.id);

            commentRepository.DeleteComment(comment);

            Guid id;
            List <CommentViewModel> models = new List <CommentViewModel>();

            if (comment.AlbumID == null)
            {
                id = (Guid)comment.PhotoID;
                List <Comment> comments = commentRepository.GetAllComentsByPhotoID(id.ToString());
                comments.ForEach(x => models.Add(CommentMapper.MapCommentViewModel(x)));
            }
            else
            {
                id = (Guid)comment.AlbumID;
                List <Comment> comments = commentRepository.GetAllComentsByAlbumID(id.ToString());
                comments.ForEach(x => models.Add(CommentMapper.MapCommentViewModel(x)));
            }

            return(PartialView("_Items", models));
        }