public ActionResult SportEventListFiltered(SportEventListViewModel viewModel) { SortedList <string, string> paramDictionary = new SortedList <string, string>(); if (viewModel.DDiscipline != 0) { paramDictionary.Add("DDisciplineID", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " " + (int)viewModel.DDiscipline); } if (!string.IsNullOrWhiteSpace(viewModel.EventDate)) { paramDictionary.Add("Date", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " '" + viewModel.EventDate + "'"); } if (!string.IsNullOrWhiteSpace(viewModel.EventTime)) { paramDictionary.Add("Time", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.GreaterEqual) + " '" + viewModel.EventTime + "'"); } paramDictionary.Add("HasEnded", EnumHelpers.GetDescriptionOfEnum(ComparisionEnum.Equal) + " 0"); viewModel.SportEventList = SportEventRepository.GetSportEventsFiltered(paramDictionary); SetEnumDDisciplineSelectList(true); return(View("Index", viewModel)); }
private void SetEnumDDisciplineSelectList(bool isSearchList) { List <SelectListItem> newList = new List <SelectListItem>(); if (isSearchList) { SelectListItem selListItem = new SelectListItem() { Value = "0", Text = "Wybierz dyscyplinę..." }; newList.Add(selListItem); } var enumDDiscipline = from DDiscipline e in Enum.GetValues(typeof(DDiscipline)) select new SelectListItem() { Value = e.ToString(), Text = EnumHelpers.GetDescriptionOfEnum(e) }; newList.AddRange(enumDDiscipline); ViewBag.EnumDDisciplineList = new SelectList(newList, "Value", "Text", "0"); }