Пример #1
0
        public ActionResult NewsFromRegion(NewsFromRegionModel model)
        {
            DateTime? fromDate = this.TryParseDateTime(model.DateFrom);
            DateTime? toDate = this.TryParseDateTime(model.DateTo);

            IList<String> regions = this._repositoryService.GetAllSlovenianRegions();
            this.PrepareNewsFromRegionModel(model, regions);

            IList<Post> posts = this._repositoryService.GetPostsFromRegion(model.SelectedRegion, fromDate: fromDate, toDate: toDate);
            model.Posts = posts;

            return View(model);
        }
Пример #2
0
        private void PrepareNewsFromRegionModel(NewsFromRegionModel model, IList<String> regions)
        {
            model = model ?? new NewsFromRegionModel();

            if (!regions.IsEmpty())
            {
                model.AllRegions = regions.Select(x =>
                {
                    var m = new SelectListItem()
                    {
                        Text = x,
                        Value = x,
                        Selected = !String.IsNullOrEmpty(model.SelectedRegion) && model.SelectedRegion == x
                    };

                    return m;
                });
            }
        }
Пример #3
0
        public ActionResult NewsFromRegion()
        {
            DateTime fromDate = new DateTime(2013, 1, 1);
            DateTime toDate = new DateTime(2014, 1, 1);
            NewsFromRegionModel model = new NewsFromRegionModel()
            {
                DateFrom = fromDate.ToShortDateString(),
                DateTo = toDate.ToShortDateString()
            };

            IList<String> regions = this._repositoryService.GetAllSlovenianRegions();
            this.PrepareNewsFromRegionModel(model, regions);

            return View(model);
        }