Ejemplo n.º 1
0
        public async Task <IActionResult> Topic(int id, int?page)
        {
            // Pagination

            int pageSize = 20;

            TopicViewModel vm = new TopicViewModel()
            {
                Topic = await _topicRepository.GetById(id),
                Posts = await _topicRepository.GetByIdWithPosts(id, page ?? 1, pageSize)
            };

            // Manually set breadcrumb nodes
            var childNode1 = new MvcBreadcrumbNode("Forum", "Home", vm.Topic.Forum.Title)
            {
                RouteValues = new { id = vm.Topic.Forum.Id }
            };
            var childNode2 = new MvcBreadcrumbNode("Topic", "Home", "ViewData.Title")
            {
                OverwriteTitleOnExactMatch = true,
                Parent = childNode1
            };

            ViewData["BreadcrumbNode"] = childNode2;

            return(View(vm));
        }
Ejemplo n.º 2
0
        public void TestEntityGetById()
        {
            var mockTeste = new Mock <IGetDB <Topic> >();

            var topicRepository = new TopicRepository(mockTeste.Object);

            topicRepository.GetById(Guid.NewGuid());

            mockTeste.Verify(x => x.GetRegisterById(It.IsAny <Guid>()));
        }
Ejemplo n.º 3
0
        public async Task <TopicDto> UpdateTopic(TopicDto topicDto)
        {
            if (topicDto.TopicName.Contains(","))
            {
                throw new FormInvalidException("", "Topic name cannot contain ','");
            }

            var topic = await _repository.GetById(topicDto.Id);

            topic = _mapper.Map(topicDto, topic);
            await _repository.Update(topic);

            return(topicDto);
        }
Ejemplo n.º 4
0
 public TopicDetailModel GetTopic(Guid id)
 {
     return(repository.GetById(id));
 }