コード例 #1
0
        //[Authorize]



        //[Authorize]
        public ActionResult Browse()
        {
            var browseFilterModel = new BrowseFilterInputModel();

            browseFilterModel.TypesData = Enum.GetValues(typeof(EventType)).Cast <EventType>().Select(x => new SelectListItem
            {
                Text  = base.GetLocalizedEventTypeString(x),
                Value = ((int)x).ToString()
            }).ToList();

            return(View(browseFilterModel));
        }
コード例 #2
0
        //[Authorize]
        public ActionResult List(BrowseFilterInputModel browseFilterModel)
        {
            var events = this.events.All().Where(x => !x.IsFinished);

            if (!string.IsNullOrWhiteSpace(browseFilterModel.SearchedEventName))
            {
                events = events.Where(x => x.Title.ToLower().Contains(browseFilterModel.SearchedEventName.ToLower()));
            }

            if (browseFilterModel.Type != null)
            {
                events = events.Where(x => x.Type == browseFilterModel.Type);
            }

            if (browseFilterModel.StartDate != null)
            {
                events = events.Where(x => x.StartDate >= browseFilterModel.StartDate);
            }

            if (browseFilterModel.EndDate != null)
            {
                events = events.Where(x => x.EndDate <= browseFilterModel.EndDate);
            }


            var model = events.Select(x => new EventViewModel
            {
                Id          = x.EventId,
                Title       = x.Title,
                Type        = x.Type,
                StartDate   = x.StartDate,
                EndDate     = x.EndDate,
                Description = x.Description
            }).ToList();

            foreach (var item in model)
            {
                item.ShortDescription = this.GetShortDescription(item.Description);
                item.LocalizedType    = base.GetLocalizedEventTypeString(item.Type);
            }

            return(PartialView(model));
        }