Exemplo n.º 1
0
        public JsonResult GetFormato()
        {
            FormatoBL formatoBL = new FormatoBL();

            GetFormatoResponseDTO formatoResponse = new GetFormatoResponseDTO();

            GetFormatoRequestDTO formatoRequest = new GetFormatoRequestDTO();

            List <CatFormato> listaFormato = new List <CatFormato>();

            formatoResponse = formatoBL.GetFormato(formatoRequest);

            if (formatoResponse.Mensaje == "OK")
            {
                listaFormato = formatoResponse.ListaFormato;
            }


            return(Json(listaFormato, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        public GetFormatoResponseDTO GetFormato(GetFormatoRequestDTO formatoRequest)
        {
            GetFormatoResponseDTO formatoResponse = new GetFormatoResponseDTO();
            List <CatFormato>     listaFormato    = new List <CatFormato>();

            FormatoDal formatoDal = new FormatoDal();
            DataTable  dtDatos    = new DataTable();

            try
            {
                dtDatos = formatoDal.GetFormato(formatoRequest.idFormato, formatoRequest.formato);

                listaFormato = dtDatos.AsEnumerable()
                               .Select(row => new CatFormato
                {
                    idFormato     = row.Field <int?>("idFormato").GetValueOrDefault(),
                    formato       = string.IsNullOrEmpty(row.Field <string>("formato")) ? "" : row.Field <string>("formato"),
                    descripcion   = string.IsNullOrEmpty(row.Field <string>("descripcion")) ? "" : row.Field <string>("descripcion"),
                    mensualidad   = row.Field <decimal?>("mensualidad").GetValueOrDefault(),
                    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();

                formatoResponse.ListaFormato = listaFormato;
                formatoResponse.Mensaje      = "OK";
            }
            catch (Exception ex)
            {
                formatoResponse.ListaFormato = new List <CatFormato>();
                formatoResponse.Mensaje      = "ERROR: " + ex.Message;
            }

            return(formatoResponse);
        }