Ejemplo n.º 1
0
        public async void GivenACommand_WhenExecuteIsCalled_TheRssEndpointIsCalled()
        {
            _httpMessageHandler.Expect(FeedUrl).Respond(ApplicationXml, FeedResponse);

            await _getPostsCommand.Execute();

            _httpMessageHandler.VerifyNoOutstandingExpectation();
        }
Ejemplo n.º 2
0
 public IActionResult Get([FromQuery] PostQuery dto)
 {
     try
     {
         return(Ok(_getPostsCommand.Execute(dto)));
     }
     catch (EntityNotFoundException)
     {
         return(NotFound());
     }
 }
Ejemplo n.º 3
0
 public ActionResult <IEnumerable <PostDto> > Get([FromQuery] PostQuery query)
 {
     try
     {
         return(Ok(_getPosts.Execute(query)));
     }
     catch (NotFoundException)
     {
         return(NotFound());
     }
 }
Ejemplo n.º 4
0
        async Task LoadPosts()
        {
            var posts = await _getPostsCommand.Execute();

            Posts.Clear();

            foreach (var post in posts)
            {
                var model = _postMapper.Map(post);
                Posts.Add(model);
            }
        }
Ejemplo n.º 5
0
        // GET: Posts
        public ActionResult Index([FromQuery] PostSearch ps)
        {
            try
            {
                var posts = _getPosts.Execute(ps);
                return(View(posts));
            }

            catch (EntityNotFoundException e) { TempData["Error"] = e.Message; }
            catch (Exception e) { TempData["Error"] = "Server error " + e.Message; }
            return(View());
        }
Ejemplo n.º 6
0
        // GET: Posts
        public ActionResult Index(string searchString, string sortOrder, PostQuery search)
        {
            ViewBag.TitleSortParam    = string.IsNullOrEmpty(sortOrder) ? "title_desc" : "";
            ViewBag.AuthorSortParam   = sortOrder == "author_desc" ? "author_asc" : "author_desc";
            ViewBag.CategorySortParam = sortOrder == "category_desc" ? "category_asc" : "category_desc";
            ViewBag.CurrentSortOrder  = sortOrder;

            ViewBag.CurrentFilter = searchString;
            var posts = _getPosts.Execute(search);

            return(View(posts));
        }
Ejemplo n.º 7
0
 public ActionResult <IEnumerable <GetPostDto> > Get([FromQuery] PostSearch search)
 {
     try
     {
         var posts = _getCommand.Execute(search);
         return(Ok(posts));
     }
     catch (EntityNotFoundException e)
     {
         return(NotFound(e.Message));
     }
     catch (Exception)
     {
         return(StatusCode(500, "Server error has occurred."));
     }
 }
Ejemplo n.º 8
0
        public async void GivenModel_WhenInitIsCalled_ThenPostsAreLoaded()
        {
            var posts = new [] { new Post(), new Post() };

            _getPostsCommand.Execute().Returns(Task.FromResult(posts as IEnumerable <Post>));

            _postViewModelMapper.Map(Arg.Any <Post>()).Returns(new PostViewModel());

            await _model.Init();

            _getPostsCommand.Received(1).Execute();

            _postViewModelMapper.Received(1).Map(posts[0]);
            _postViewModelMapper.Received(1).Map(posts[1]);

            _model.Posts.Count.Should().Be(2);
        }
Ejemplo n.º 9
0
 // GET: Posts
 public ActionResult Index([FromQuery] PostSearch search)
 {
     try
     {
         var posts = _getCommand.Execute(search);
         return(View(posts.Data));
     }
     catch (EntityNotFoundException)
     {
         return(RedirectToAction(nameof(Index)));
     }
     catch (Exception)
     {
         TempData["error"] = "Server error has occurred.";
         return(RedirectToAction(nameof(Index)));
     }
 }
Ejemplo n.º 10
0
        // GET: Posts
        public ActionResult Index(PostSearch search)
        {
            var posts = _getPosts.Execute(search);

            return(View(posts));
        }
Ejemplo n.º 11
0
 public ActionResult <IEnumerable <PostDTO> > Get([FromQuery] PostSearch query)
 {
     return(Ok(_getCommand.Execute(query)));
 }