Beispiel #1
0
 public void CreateComment(PhotoCommentDTO photoCommentDto)
 {
     using (UnitOfWork unitOfWork = new UnitOfWork(new PhotoManagerDbContext()))
     {
         PhotoComment photoComment = Mapper.Map <PhotoComment>(photoCommentDto);
         photoComment.Created = DateTime.Now;
         photoComment.UserId  = WebSecurityService.GetCurrentUser().UserId;
         unitOfWork.PhotoComments.Add(photoComment);
         unitOfWork.Complete();
     }
 }
Beispiel #2
0
        public ActionResult CreateComment(PhotoCommentViewModel photoCommentViewModel)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("EmptyMessageError", "You can't post empty message");
                return(RedirectToAction("Details", new { id = photoCommentViewModel.PhotoId }));
            }
            PhotoCommentDTO photoCommentDto = Mapper.Map <PhotoCommentDTO>(photoCommentViewModel);

            _commentServices.CreateComment(photoCommentDto);
            return(RedirectToAction("Details", new { id = photoCommentViewModel.PhotoId }));
        }