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)); } }
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)); } }
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)); }
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)); }
public ActionResult Index() { var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper(); return(View(mapper.Map <IEnumerable <Article> >(_articleService.GetArticles()))); }
public ActionResult Index() { var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper(); return(View(mapper.Map <IEnumerable <Review> >(_reviewService.GetReviews()))); }
public ActionResult DisplayComments(string id) { var mapper = MapperConfigWeb.GetConfigFromDTO().CreateMapper(); return(PartialView("~/Views/Comment/Partials/DisplayComments.cshtml", mapper.Map <IEnumerable <Comment> >(_commentService.GetComments(id)))); }