コード例 #1
0
        private async Task <List <SelectListItem> > ListarFamiliaAsync()
        {
            var familias = await _familiaService.ListarAsync();

            if (familias.Any())
            {
                return(familias.Select(x => new SelectListItem {
                    Text = x.Nome, Value = x.Id.ToString()
                }).ToList());
            }

            return(new List <SelectListItem> {
                new SelectListItem {
                    Text = "Selecione"
                }
            });
        }
コード例 #2
0
 public async Task <IActionResult> Listar()
 {
     return(Json(await _familiaService.ListarAsync()));
 }