示例#1
0
        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));
        }
示例#2
0
        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);
        }