public IEnumerable <SelectListItem> GetManufacturerModels(int manufacturerId)
 {
     if (manufacturerId > 0)
     {
         using (var context = new SDCEntities())
         {
             IEnumerable <SelectListItem> manufacturermodels = context.ManufacturerModels.AsNoTracking()
                                                               .OrderBy(n => n.Name)
                                                               .Where(n => n.ManufacturerID == manufacturerId)
                                                               .Select(n =>
                                                                       new SelectListItem
             {
                 Value = n.ManufacturerID.ToString(),
                 Text  = n.Name
             }).ToList();
             return(new SelectList(manufacturermodels, "Value", "Text"));
         }
     }
     return(null);
 }
Exemple #2
0
 public IEnumerable <SelectListItem> GetManufacturers()
 {
     using (var context = new SDCEntities())
     {
         List <SelectListItem> manufacturers = context.Manufacturers.AsNoTracking()
                                               .OrderBy(n => n.Name)
                                               .Select(n =>
                                                       new SelectListItem
         {
             Value = n.ManufacturerID.ToString(),
             Text  = n.Name
         }).ToList();
         var tooltip = new SelectListItem()
         {
             Value = null,
             Text  = "--- select manufacturers ---"
         };
         manufacturers.Insert(0, tooltip);
         return(new SelectList(manufacturers, "Value", "Text"));
     }
 }