Exemplo n.º 1
0
        public ActionResult ChangeLikes(int photoId)
        {
            var user = accountService.GetUserByUserName(User.Identity.Name)?.ToMvcUser();

            photoService.ChangeNumberOfLikes(photoId, user.Id);

            var photo = photoService.GetById(photoId)?.ToMvcPhoto();

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_likes", photo));
            }

            user = accountService.GetByUserId(photo.UserId)?.ToMvcUser();
            var paging = photoService.GetCommentsPaging(photoId, commentPageSize, 1, null).ToMvcCommentsPaging();

            var photoDetail = new PhotoCommentViewModel
            {
                User          = user,
                Photo         = photo,
                CommentPaging = paging
            };

            return(View("PhotoDetails", photoDetail));
        }