I need to create a Helper to build Dropdownlists used in several Controller Methods.
namespace Heelp.Helpers
{
public class PTDistrictHelpers
{
public IEnumerable<SelectListItem> DropDownList(IList<PTDistrictDto> ptDistrictsDto, int selectedValue = GlobalConstants.DROPDOWNLIST_NO_SELECTED_VALUE)
{
var ptDistrictsViewModel = Mapper.Map<IList<PTDistrictDto>, IList<PTDistrictViewModel>>(ptDistrictsDto);
var ptDistrictsList = ptDistrictsViewModel.Select(district =>
new SelectListItem
{
Value = district.Id.ToString(),
Text = district.Name,
Selected = (district.Id == selectedValue)
});
return ptDistrictsList;
}
}
}
The Controller method:
[AllowAnonymous]
public virtual PartialViewResult AdvancedSearch()
{
// District
var dropdown = new Heelp.Helpers.PTDistrictHelpers();
dropdown. <== The DropDownList method don't appears when I hit the "." why?
}
The idea is to have a class in the Web Project where I can put all the code I will user in several places in the project that calls Service Layer Method not available in the Business Layer because they are related with the Web Layer like SelectListItem