コード例 #1
0
        public IActionResult Index(string filter, int page = 1,
                                   string sortExpression   = "Name")
        {
            var stories = _storyService.GetAll().Select(x => new StoryDetailViewModel
            {
                Id          = x.Id.ToString(),
                Name        = x.Name,
                Reporter    = x.Reporter,
                Description = x.Description,
                Point       = x.Point
            });

            //var model = new StoryIndexViewModel
            //{
            //    Stories = stories
            //};

            //return View(model);
            if (!string.IsNullOrWhiteSpace(filter))
            {
                stories = stories.Where(p => p.Name.Contains(filter));
            }
            var model = PagingList.Create(stories, 5, page, sortExpression, "Name");

            model.RouteValue = new RouteValueDictionary {
                { "filter", filter }
            };
            return(View(model));
        }
コード例 #2
0
 public IHttpActionResult Get()
 {
     return(Ok(_storyService.GetAll().Select(story => new StoryViewModel
     {
         Name = story.Name,
         Teller = story.Teller.FirstName + " " + story.Teller.LastName
     })));
 }
コード例 #3
0
        public IActionResult List()
        {
            var model = _storyService.GetAll();

            return(View(model));
        }
コード例 #4
0
 public async Task <IEnumerable <Article> > GetItemsAsync(bool forceRefresh = false)
 {
     return(await _storyService.GetAll());
 }
コード例 #5
0
        public IActionResult GetAll()
        {
            var stories = _storyService.GetAll();

            return Ok(stories);
        }