public ActionResult Detailed(int id) { if (id < 1) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } this.ViewBag.TopicId = id; DetailedTopicViewModel viewModel = this.service.DetailedTopic(id); return(this.View(viewModel)); }
public DetailedTopicViewModel DetailedTopic(int id) { Topic topic = this.Context.Topics.Find(id); if (topic == null) { throw new ArgumentNullException(nameof(id), "There is no Topic with such Id.");; } DetailedTopicViewModel viewModel = Mapper.Instance.Map <DetailedTopicViewModel>(topic); viewModel.Replies = Mapper.Map <IEnumerable <ReplyViewModel> >(topic.Replies); return(viewModel); }