/// <summary> /// Método que agrega un registro a la tabla de validaciones /// </summary> /// <param name="validacion_documento"></param> /// <param name="descripcion"></param> /// <returns></returns> public int SetValidacion(string validacion_documento, string descripcion, DateTime date_now) { try { //Establecemos la conexión a la BD. using (var Conexion = new EntitiesControlDocumentos()) { TBL_VALIDACION_DOCUMENTO obj = new TBL_VALIDACION_DOCUMENTO(); //Asigamos los valores obj.VALIDACION_DOCUMENTO = validacion_documento; obj.VALIDACION_DESCRIPCION = descripcion; obj.FECHA_ACTUALIZACION = date_now; obj.FECHA_CREACION = date_now; //Añadimos el objeto Conexion.TBL_VALIDACION_DOCUMENTO.Add(obj); //Guardamos los cambios Conexion.SaveChanges(); //Retornamos el id del objeto agregado return(obj.ID_VALIDACION_DOCUMENTO); } } catch (Exception) { //Si hay error regresamos cero return(0); } }
/// <summary> /// Método que elimina un registro de la tabla de validaciones /// </summary> /// <param name="id_validacion"></param> /// <returns></returns> public int DeleteValidacion(int id_validacion) { try { //Establecemos la conexión a la BD. using (var Conexion = new EntitiesControlDocumentos()) { TBL_VALIDACION_DOCUMENTO obj = Conexion.TBL_VALIDACION_DOCUMENTO.Where(x => x.ID_VALIDACION_DOCUMENTO == id_validacion).FirstOrDefault(); //Guaramos el estado Conexion.Entry(obj).State = EntityState.Deleted; //Se guardan los cambios y retorna el número de registros afectados. return(Conexion.SaveChanges()); } } catch (Exception) { //Si hay error regresamos cero return(0); } }