public async void GivenACommand_WhenExecuteIsCalled_TheRssEndpointIsCalled() { _httpMessageHandler.Expect(FeedUrl).Respond(ApplicationXml, FeedResponse); await _getPostsCommand.Execute(); _httpMessageHandler.VerifyNoOutstandingExpectation(); }
public IActionResult Get([FromQuery] PostQuery dto) { try { return(Ok(_getPostsCommand.Execute(dto))); } catch (EntityNotFoundException) { return(NotFound()); } }
public ActionResult <IEnumerable <PostDto> > Get([FromQuery] PostQuery query) { try { return(Ok(_getPosts.Execute(query))); } catch (NotFoundException) { return(NotFound()); } }
async Task LoadPosts() { var posts = await _getPostsCommand.Execute(); Posts.Clear(); foreach (var post in posts) { var model = _postMapper.Map(post); Posts.Add(model); } }
// 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()); }
// 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)); }
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.")); } }
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); }
// 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))); } }
// GET: Posts public ActionResult Index(PostSearch search) { var posts = _getPosts.Execute(search); return(View(posts)); }
public ActionResult <IEnumerable <PostDTO> > Get([FromQuery] PostSearch query) { return(Ok(_getCommand.Execute(query))); }