コード例 #1
0
        public GetNivelResponseDTO GetNivel(GetNivelRequestDTO nivelRequest)
        {
            GetNivelResponseDTO nivelResponse = new GetNivelResponseDTO();
            List <CatNivel>     listaNivel    = new List <CatNivel>();

            NivelDal  nivelDal = new NivelDal();
            DataTable dtDatos  = new DataTable();

            try
            {
                dtDatos = nivelDal.GetNivel(nivelRequest.idNivel, nivelRequest.nivel);

                listaNivel = dtDatos.AsEnumerable()
                             .Select(row => new CatNivel
                {
                    idNivel       = row.Field <int?>("idNivel").GetValueOrDefault(),
                    nivel         = string.IsNullOrEmpty(row.Field <string>("nivel")) ? "" : row.Field <string>("nivel"),
                    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();

                nivelResponse.ListaNivel = listaNivel;
                nivelResponse.Mensaje    = "OK";
            }
            catch (Exception ex)
            {
                nivelResponse.ListaNivel = new List <CatNivel>();
                nivelResponse.Mensaje    = "ERROR: " + ex.Message;
            }

            return(nivelResponse);
        }
コード例 #2
0
        public JsonResult GetNivel()
        {
            NivelBL nivelBL = new NivelBL();

            GetNivelResponseDTO nivelResponse = new GetNivelResponseDTO();

            GetNivelRequestDTO nivelRequest = new GetNivelRequestDTO();

            List <CatNivel> listaNivel = new List <CatNivel>();

            nivelResponse = nivelBL.GetNivel(nivelRequest);

            if (nivelResponse.Mensaje == "OK")
            {
                listaNivel = nivelResponse.ListaNivel;
            }


            return(Json(listaNivel, JsonRequestBehavior.AllowGet));
        }