Exemplo n.º 1
0
        public static List <SelectListItem> GetSelectListItems()
        {
            var selectList = new List <SelectListItem>();

            using (var context = new VolvoTrucksContext())
            {
                var list = context.TruckModels.OrderBy(x => x.ModelName).ToList();

                list.ForEach(x =>
                {
                    selectList.Add(new SelectListItem
                    {
                        Value = x.ModelId.ToString(),
                        Text  = x.ModelName
                    });
                });
            }

            return(selectList);
        }
 public TruckModelsController(VolvoTrucksContext context)
 {
     _context = context;
 }
Exemplo n.º 3
0
 public void Setup()
 {
     _context    = new VolvoTrucksContext();
     _controller = new TruckController();
 }