public GetClubResponseDTO GetClub(GetClubRequestDTO clubRequest) { GetClubResponseDTO clubResponse = new GetClubResponseDTO(); List <CatClub> listaClub = new List <CatClub>(); ClubDal clubDal = new ClubDal(); DataTable dtDatos = new DataTable(); try { dtDatos = clubDal.GetClub(clubRequest.idClub, clubRequest.club); listaClub = dtDatos.AsEnumerable() .Select(row => new CatClub { idClub = row.Field <int?>("idClub").GetValueOrDefault(), club = string.IsNullOrEmpty(row.Field <string>("club")) ? "" : row.Field <string>("club"), descripcion = string.IsNullOrEmpty(row.Field <string>("descripcion")) ? "" : row.Field <string>("descripcion"), usuarioInsert = string.IsNullOrEmpty(row.Field <string>("usuarioInsert")) ? "" : row.Field <string>("usuarioInsert"), fechaInsert = row.Field <DateTime?>("fechaInsert").GetValueOrDefault(), usuarioUpdate = string.IsNullOrEmpty(row.Field <string>("usuarioUpdate")) ? "" : row.Field <string>("usuarioUpdate"), fechaUpdate = row.Field <DateTime?>("fechaUpdate").GetValueOrDefault(), }).ToList(); clubResponse.ListaClub = listaClub; clubResponse.Mensaje = "OK"; } catch (Exception ex) { clubResponse.ListaClub = new List <CatClub>(); clubResponse.Mensaje = "ERROR: " + ex.Message; } return(clubResponse); }
public JsonResult GetClub() { ClubBL clubBL = new ClubBL(); GetClubResponseDTO clubResponse = new GetClubResponseDTO(); GetClubRequestDTO clubRequest = new GetClubRequestDTO(); List <CatClub> listaClub = new List <CatClub>(); clubResponse = clubBL.GetClub(clubRequest); if (clubResponse.Mensaje == "OK") { listaClub = clubResponse.ListaClub; } return(Json(listaClub, JsonRequestBehavior.AllowGet)); }