Beispiel #1
0
        public IActionResult Index()
        {
            HomeViewModel model = new HomeViewModel();

            FillModelWithBasicUserData(model);
            FillModelWithNews(model);

            return View(model);
        }
Beispiel #2
0
        private void FillModelWithNews(HomeViewModel model)
        {
            var result = _newsService.GetAll(withContent: false);

            if (result.IsSuccess)
            {
                var allNewsItem = result.Item;

                var ordered = allNewsItem
                    .OrderByDescending(x => x.Id);

                if (allNewsItem.Count() > 0)
                {
                    model.MainNews = Mapper.Map<NewsThumbnailViewModel>(ordered.First());
                }

                if (allNewsItem.Count() > 1)
                {
                    model.SmallNews = ordered.Skip(1).Take(3).Select(x => Mapper.Map<NewsThumbnailViewModel>(x));
                }
            }
        }
Beispiel #3
0
 private void FillModelWithBasicUserData(HomeViewModel model)
 {
     model.UserData = Mapper.Map<UserProfileViewModel>(_userService.GetUserProfile(StaticManager.UserName).Item);
 }