Esempio n. 1
0
        public async Task <int> DeleteStock(Models.Stock stock)
        {
            var cnd = new Condition("ID", Convert.ToString(stock.Id), BinaryOperators.Equal);
            Dictionary <LogicOperators, Condition> conditions = new Dictionary <LogicOperators, Condition> {
                { LogicOperators.FirstCondition, cnd }
            };
            var query   = new DeleteQuery(Tables.StockTable, conditions);
            var command = new SqlCommand(query.ToString(), _connection);

            return(await command.ExecuteNonQueryAsync());
        }
Esempio n. 2
0
        public async Task <int> Delete <T>(T element, string tableName)
        {
            var model = (IBaseModel)element;
            var cnd   = new Condition("ID", Convert.ToString(model.Id), BinaryOperators.Equal);
            Dictionary <LogicOperators, Condition> conditions = new Dictionary <LogicOperators, Condition> {
                { LogicOperators.FirstCondition, cnd }
            };
            var query   = new DeleteQuery(tableName, conditions);
            var command = new SqlCommand(query.ToString(), _connection);

            return(await command.ExecuteNonQueryAsync());
        }