Ejemplo n.º 1
0
 public ActionResult DisplayArticle(string id)
 {
     if (id == null)
     {
         return(HttpNotFound());
     }
     try
     {
         var article = _articleService.GetArticle(id);
         var mapper  = MapperConfigWeb.GetConfigFromDTO().CreateMapper();
         return(View(mapper.Map <Article>(article)));
     }
     catch (ValidationException ex)
     {
         return(View("Error", ex));
     }
 }
Ejemplo n.º 2
0
 public ActionResult Search(string tag)
 {
     if (tag == null)
     {
         tag = "";
     }
     try
     {
         var articles     = _articleService.GetArticles(tag);
         var mapper       = MapperConfigWeb.GetConfigFromDTO().CreateMapper();
         var articlesView = mapper.Map <IEnumerable <Article> >(articles);
         return(View(new SearchByTag {
             Articles = articlesView.ToList(), TagText = tag
         }));
     }
     catch (Exception ex)
     {
         return(View("Error", ex));
     }
 }
Ejemplo n.º 3
0
        public ActionResult Index(Review review)
        {
            var mapper = MapperConfigWeb.GetConfigToDTO().CreateMapper();

            try
            {
                review.Id   = Guid.NewGuid().ToString();
                review.Date = DateTime.UtcNow;
                var reviewDto = mapper.Map <ReviewDTO>(review);
                _reviewService.CreateReview(reviewDto);
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
            }
            mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();
            var model = mapper.Map <IEnumerable <Review> >(_reviewService.GetReviews());

            return(PartialView("Partials/ReviewList", model));
        }
Ejemplo n.º 4
0
        public ActionResult Index(Comment comment)
        {
            var mapper = MapperConfigWeb.GetConfigToDTO().CreateMapper();

            try
            {
                comment.Id   = Guid.NewGuid().ToString();
                comment.Date = DateTime.UtcNow;
                comment.User = User.Identity.Name;
                var reviewDto = mapper.Map <CommentDTO>(comment);
                _commentService.CreateComment(reviewDto);
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
            }
            mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();
            var model = mapper.Map <IEnumerable <Review> >(_commentService.GetComments(comment.IdArticle));

            return(PartialView("~/Views/Comment/Partials/DisplayComments.cshtml", model));
        }
Ejemplo n.º 5
0
        public ActionResult Index()
        {
            var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();

            return(View(mapper.Map <IEnumerable <Article> >(_articleService.GetArticles())));
        }
Ejemplo n.º 6
0
        public ActionResult Index()
        {
            var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();

            return(View(mapper.Map <IEnumerable <Review> >(_reviewService.GetReviews())));
        }
Ejemplo n.º 7
0
        public ActionResult DisplayComments(string id)
        {
            var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper();

            return(PartialView("~/Views/Comment/Partials/DisplayComments.cshtml", mapper.Map <IEnumerable <Comment> >(_commentService.GetComments(id))));
        }