public IEnumerable <CpspDtoModel> GetAllCpsp() { var cpspList = _commonDataRepository.GetAllCpsp().ToList(); var cpspDtoList = new List <CpspDtoModel>(); cpspList.ForEach(cp => cpspDtoList.Add(new CpspDtoModel { Id = cp.Id, Nombre = cp.Nombre })); return(cpspDtoList); }
public IEnumerable <CpspDtoModel> GetAllCpsp() { var list = _commonDataRepository.GetAllCpsp().ToList(); var cpspDtoList = new List <CpspDtoModel>(); foreach (var cp in list) { cpspDtoList.Add(new CpspDtoModel { Id = cp.Id, Nombre = string.IsNullOrEmpty(cp.Nombre) ? string.Empty : cp.Nombre, Provincia = cp.IdProvincia == null ? null : GetProvincia(cp.IdProvincia), Canton = cp.IdCanton == null ? null : GetCanton(cp.IdCanton), Distrito = cp.IdDistrito == null ? null : GetDistrito(cp.IdDistrito), }); } return(cpspDtoList); }