public CommentCreateViewModel BuildCreate(Comment comment)
        {
            if (comment == null)
            {
                throw new ArgumentNullException("comment");
            }

            var result = new CommentCreateViewModel();
            result.Key = comment.Key;
            result.CreationDate = comment.CreationDate;
            result.Content = comment.Content;
            return result;
        }
        public Comment BuildComment(CommentCreateViewModel viewModel)
        {
            if (viewModel == null)
            {
                throw new ArgumentNullException("viewModel");
            }

            var result = new Comment();
            result.Rate = 0;
            result.CreationDate = DateTime.UtcNow;
            result.Content = viewModel.Content;
            return result;
        }
        public ActionResult CreateComment(int? imageKey, CommentCreateViewModel viewModel)
        {
            bool result = false;
            var user = this.User.Identity as CustomIdentity;
            if (this.ModelState.IsValid && viewModel != null)
            {
                try
                {
                    User owner = this._membershipService.GetUserByKey(user.Id);
                    Image image = this._imageAlbumService.GetImageByKey(imageKey.Value);
                    Comment comment = this._commentMapper.BuildComment(viewModel);
                    comment.Owner = owner;
                    comment.Image = image;
                    this._commentService.CreateComment(owner, image, comment);
                    result = true;
                }
                catch (Exception)
                {
                    this.ModelState.AddModelError(string.Empty, Resources.Resources.OperationFailure);
                }
            }
            else
            {
                this.ModelState.AddModelError(string.Empty, Resources.Resources.OperationFailure);
            }

            if (result)
            {
                return this.Json(new { success = result });
            }
            return this.PartialView("_CreateComment", viewModel);
        }
        public PartialViewResult CreateComment(int? imageKey)
        {
            //ViewBag.Key = RouteData.Values["key"];
            //ViewBag.AlbumKey = RouteData.Values["albumKey"];
            //ViewBag.ImageKey = RouteData.Values["imageKey"];

            var result = new CommentCreateViewModel();
            return this.PartialView("_CreateComment", result);
        }
 public ActionResult RemoveComment(CommentCreateViewModel viewModel)
 {
     bool result = false;
     if (viewModel != null)
     {
         try
         {
             Comment comment = this._commentService.GetCommentByKey(viewModel.Key);
             if (comment != null)
             {
                 result = this._commentService.RemoveComment(comment);
             }
             else
             {
                 this.TempData[Constants.TempDataErrorMessage] = "Comment is missing.";
                 return this.PartialView("_ErrorModal");
             }
         }
         catch (Exception ex)
         {
             this.TempData[Constants.TempDataErrorMessage] = ex.Message;
             return this.PartialView("_ErrorModal");
         }
     }
     else
     {
         this.TempData[Constants.TempDataErrorMessage] = "Comment is missing.";
         return this.PartialView("_ErrorModal");
     }
     if (result)
     {
         return this.Json(new { success = result });
     }
     return this.PartialView("_Success");
 }