예제 #1
0
 public ActionResult <ViewModels.ArticleComment> Read(long id)
 {
     try
     {
         var dataModel = _repository.Read(id);
         var viewModel = _mapper.Map <ViewModels.ArticleComment>(dataModel);
         return(viewModel);
     }
     catch (Exception ex)
     {
         var input           = new { Id = id };
         var messageResponse = _errorGenerator.GetMessageResponse <DataModels.ArticleComment, object>(ActionType.Read, input, exception: ex);
         Log.Error(messageResponse.LogTemplate, messageResponse.Message, input);
         throw new Exception(messageResponse.Message);
     }
 }
예제 #2
0
        public ActionResult Delete(int commentId)
        {
            var articleComment = _articleCommentRepository.Read(commentId);

            if (articleComment == null)
            {
                return(HttpNotFound());
            }

            try
            {
                _articleCommentRepository.Delete(articleComment);
            }
            catch
            {
                TempData["error"] = ProjectConfiguration.Get.DataErrorMessage;
            }

            return(RedirectToAction("Details", "Article", new { id = articleComment.ArticleId }));
        }