Esempio n. 1
0
        public async Task <bool> RemoveAsync(CuentaMayor cuenta, aVMTabBase VM)
        {
            if (!this._ObjModels.ContainsKey(cuenta.Id))
            {
                return(false);
            }

            QueryBuilder SQL = await Task.Run(() => GetDeleteSQL(cuenta.Id)).ConfigureAwait(false);

            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal, 1);
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(SQL, condition);

            if (!await AddTransactionWaitingForCommitAsync(tuple, VM))
            {
                return(false);
            }
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RemoveObjectWaitingForCommitAsync(cuenta, VM).Forget().ConfigureAwait(false);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed

            await base._RepoSphr.WaitAsync();

            int idump;
            Tuple <int, long> key = new Tuple <int, long>(cuenta.NumCuenta, cuenta.IdOwnerComunidad.CantorPair(cuenta.IdOwnerEjercicio));
            this._CuentasIds.TryRemove(key, out idump);

            base._RepoSphr.Release();
            return(true);
        }
Esempio n. 2
0
        public async Task <bool> AddNewAsync(CuentaMayor cuenta, aVMTabBase VM)
        {
            //¡¡¡¡OJO!!!!! AQUI HAY QUE AÑADIR "SELECT LAST_INSERT_ID()" MANUALMENTE AL QUERYBUILDER
            //El problema es que LAST_INSERT_ID() trabaja por conexion, por tanto si se realizan varios inserts no serviría de nada
            if (!base._NewObjects[VM].Add(cuenta))
            {
                return(false);
            }

            QueryBuilder SQL = await Task.Run(() => GetInsertSQL(cuenta)).ConfigureAwait(false);

            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.greater, -1);

            SQL.Append("SELECT LAST_INSERT_ID();");
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(SQL, condition);

            await base._RepoSphr.WaitAsync();

            this._CuentasIds.TryAdd(
                new Tuple <int, long>(cuenta.NumCuenta, cuenta.IdOwnerComunidad.CantorPair(cuenta.IdOwnerEjercicio)),
                cuenta.Id);
            base._RepoSphr.Release();

            if (!await AddTransactionWaitingForCommitAsync(tuple, VM))
            {
                base._NewObjects[VM].Remove(cuenta);
                return(false);
            }
            return(true);
        }
Esempio n. 3
0
        public async Task <bool> UpdateAsync(Persona p, aVMTabBase VM)
        {
            Task <QueryBuilder>           SQL       = Task.Run(() => GetUpdateSQL(p.Id, VM));
            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal, 1);

            if (await SQL.ConfigureAwait(false) == null)
            {
                return(false);
            }
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(SQL.Result, condition);

            return(await AddTransactionWaitingForCommitAsync(tuple, VM));
        }
Esempio n. 4
0
        public async Task <bool> UpdateAsync(CuentaMayor cuenta, aVMTabBase VM)
        {
            QueryBuilder SQL = await Task.Run(() => GetUpdateSQL(cuenta.Id, VM)).ConfigureAwait(false);

            if (SQL == null)
            {
                return(false);
            }

            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal, 1);
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(SQL, condition);

            return(await AddTransactionWaitingForCommitAsync(tuple, VM));
        }
Esempio n. 5
0
        public async Task <bool> UpdateAsync(Asiento AsientoObj, aVMTabBase VM)
        {
            QueryBuilder SQL = await Task.Run(() => GetUpdateSQL(AsientoObj.Id, VM)).ConfigureAwait(false);

            if (SQL == null)
            {
                return(false);
            }

            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal,
                                                                                        SQL.CountNumberOfOcurrencesInQuery("UPDATE"));
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(SQL, condition);

            return(await AddTransactionWaitingForCommitAsync(tuple, VM));
        }
Esempio n. 6
0
        public async Task <bool> AddNewAsync(Persona p, aVMTabBase VM)
        {
            if (!this._NewObjects[VM].Add(p))
            {
                return(false);
            }

            Task <QueryBuilder>           SQL       = Task.Run(() => GetInsertSQL(p));
            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal, 1);
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(await SQL.ConfigureAwait(false), condition);

            if (!await AddTransactionWaitingForCommitAsync(tuple, VM))
            {
                base._NewObjects[VM].Remove(p);
                return(false);
            }
            return(true);
        }
Esempio n. 7
0
        public async Task <bool> RemoveAsync(Persona p, aVMTabBase VM)
        {
            if (!this._ObjModels.ContainsKey(p.Id))
            {
                return(false);
            }

            Task <QueryBuilder>           SQL       = Task.Run(() => GetDeleteSQL(p.Id));
            ConditionToCommitScalar <int> condition = new ConditionToCommitScalar <int>(ConditionTCType.equal, 1);
            var tuple = new Tuple <QueryBuilder, IConditionToCommit>(await SQL.ConfigureAwait(false), condition);

            if (!await AddTransactionWaitingForCommitAsync(tuple, VM))
            {
                return(false);
            }
#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            RemoveObjectWaitingForCommitAsync(p, VM).Forget().ConfigureAwait(false);
#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed
            return(true);
        }