예제 #1
0
        public IActionResult PrestamoTipo(int id)
        {
            try
            {
                bool         eliminado    = false;
                PrestamoTipo prestamoTipo = PrestamoTipoDAO.getPrestamoTipoPorId(id);
                if (prestamoTipo != null)
                {
                    eliminado = PrestamoTipoDAO.eliminarPrestamoTipo(prestamoTipo);
                }

                return(Ok(new { success = eliminado }));
            }
            catch (Exception e)
            {
                CLogger.write("5", "PrestamoTipoController.class", e);
                return(BadRequest(500));
            }
        }
예제 #2
0
        public static bool eliminarPrestamoTipo(PrestamoTipo prestamoTipo)
        {
            bool ret = false;

            try
            {
                using (DbConnection db = new OracleContext().getConnection())
                {
                    prestamoTipo.estado = 0;
                    bool eliminado = guardarPrestamoTipo(prestamoTipo);
                    ret = eliminado;
                }
            }
            catch (Exception e)
            {
                CLogger.write("6", "PrestamoTipoDAO", e);
            }
            return(ret);
        }
예제 #3
0
        public IActionResult PrestamoTipo([FromBody] dynamic value)
        {
            try
            {
                PrestamoTipoValidator validator = new PrestamoTipoValidator();
                ValidationResult      results   = validator.Validate(value);

                if (results.IsValid)
                {
                    PrestamoTipo prestamoTipo = new PrestamoTipo();
                    prestamoTipo.nombre        = value.nombre != null ? (string)value.nombre : default(string);
                    prestamoTipo.descripcion   = value.descripcion != null ? (string)value.descripcion : default(string);
                    prestamoTipo.estado        = 1;
                    prestamoTipo.usuarioCreo   = User.Identity.Name;
                    prestamoTipo.fechaCreacion = DateTime.Now;

                    bool guardado = PrestamoTipoDAO.guardarPrestamoTipo(prestamoTipo);

                    return(Ok(new
                    {
                        success = guardado,
                        id = prestamoTipo.id,
                        usuarioCreo = prestamoTipo.usuarioCreo,
                        fechaCreacion = prestamoTipo.fechaCreacion.ToString("dd/MM/yyyy H:mm:ss"),
                        usuarioActualizo = prestamoTipo.usuarioActualizo,
                        fechaActualizacion = prestamoTipo.fechaActualizacion != null ? prestamoTipo.fechaActualizacion.Value.ToString("dd/MM/yyyy H:mm:ss") : null
                    }));
                }
                else
                {
                    return(Ok(new { success = true }));
                }
            }
            catch (Exception e)
            {
                CLogger.write("3", "PrestamoTipoController.class", e);
                return(BadRequest(500));
            }
        }