public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
        {
            if (row == null) throw new ArgumentNullException("row");

            ExecAction(db =>
            {
                var counter = db.ExecScalar<long>(Query(tenants_quotarow, row.Tenant)
                    .Select("counter")
                    .Where("path", row.Path));

                db.ExecNonQuery(Insert(tenants_quotarow, row.Tenant)
                    .InColumnValue("path", row.Path)
                    .InColumnValue("counter", exchange ? counter + row.Counter : row.Counter)
                    .InColumnValue("tag", row.Tag)
                    .InColumnValue("last_modified", DateTime.UtcNow));
            });
        }
 public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
 {
     service.SetTenantQuotaRow(row, exchange);
     interval.Expire();
 }
 public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
 {
     quotaService.SetTenantQuotaRow(row, exchange);
 }
        public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
        {
            if (row == null) throw new ArgumentNullException("row");

            using (var db = GetDb())
            using (var tx = db.BeginTransaction())
            {
                var counter = db.ExecuteScalar<long>(Query(tenants_quotarow, row.Tenant)
                    .Select("counter")
                    .Where("path", row.Path));

                db.ExecuteNonQuery(Insert(tenants_quotarow, row.Tenant)
                    .InColumnValue("path", row.Path)
                    .InColumnValue("counter", exchange ? counter + row.Counter : row.Counter)
                    .InColumnValue("tag", row.Tag)
                    .InColumnValue("last_modified", DateTime.UtcNow));

                tx.Commit();
            }
        }
        public void SetTenantQuotaRow(TenantQuotaRow row, bool exchange)
        {
            if (row == null) throw new ArgumentNullException("row");

            ExecAction(db =>
            {
                var counter = db.ExecScalar<long?>(Query(tenants_quotarow, row.Tenant)
                    .Select("counter")
                    .Where("path", row.Path));

                if (counter.HasValue)
                {
                    db.ExecNonQuery(Update(tenants_quotarow, row.Tenant)
                        .Set("counter", exchange ? counter.Value + row.Counter : row.Counter)
                        .Set("last_modified", DateTime.UtcNow)
                        .Where(Exp.Eq("path", row.Path)));
                    //db.ExecNonQuery(Insert(tenants_quotarow, row.Tenant)
                    //    .InColumnValue("path", row.Path)
                    //    .InColumnValue("counter", exchange ? counter.Value + row.Counter : row.Counter)
                    //    .InColumnValue("tag", row.Tag)
                    //    .InColumnValue("last_modified", DateTime.UtcNow));
                }
                else
                {
                    //ok
                    db.ExecNonQuery(Insert(tenants_quotarow, row.Tenant)
                    .InColumnValue("path", row.Path)
                    .InColumnValue("counter", row.Counter)
                    .InColumnValue("tag", row.Tag)
                    .InColumnValue("last_modified", DateTime.UtcNow));
                }
            });
        }