コード例 #1
0
 public IEnumerable <SelectListItem> GetMunicipios(int cod)
 {
     if (cod != 0)
     {
         using (var context = new MedEvolutionDbContext())
         {
             IEnumerable <SelectListItem> municipios = context.Municipio.AsNoTracking()
                                                       .OrderBy(n => n.CodigoDepartamento)
                                                       .Where(n => n.CodigoDepartamento == cod)
                                                       .Select(n =>
                                                               new SelectListItem
             {
                 Value = n.CodigoMunicipio.ToString(),
                 Text  = n.NombreMun
             }).ToList();
             return(new SelectList(municipios, "Value", "Text"));
         }
     }
     return(null);
 }
コード例 #2
0
 public IEnumerable <SelectListItem> GetDepartamentos()
 {
     using (var context = new MedEvolutionDbContext())
     {
         List <SelectListItem> departamentos = context.Departamento.AsNoTracking()
                                               .OrderBy(n => n.CodigoDepartamento)
                                               .Select(n =>
                                                       new SelectListItem
         {
             Value = n.CodigoDepartamento.ToString(),
             Text  = n.NombreDep
         }).ToList();
         var countrytip = new SelectListItem()
         {
             Value = null,
             Text  = "--- select country ---"
         };
         departamentos.Insert(0, countrytip);
         return(new SelectList(departamentos, "Value", "Text"));
     }
 }