public int Add(string id, CounterOperation op) { op.DocumentId = id; _list.Add(op); return(_list.Count); }
public Task DecrementAsync(string counter, int amount) { var entity = new CounterOperation(PartitionKeyFor(counter, DecrementKey), amount); var op = TableOperation.Insert(entity); return(_table.ExecuteAsync(op)); }
public void Increment(string counter, long delta = 1) { if (string.IsNullOrWhiteSpace(counter)) { throw new ArgumentNullException(nameof(counter)); } var counterOp = new CounterOperation { Type = CounterOperationType.Increment, CounterName = counter, Delta = delta }; if (Session.DocumentsById.TryGetValue(DocId, out DocumentInfo documentInfo) && Session.DeletedEntities.Contains(documentInfo.Entity)) { ThrowDocumentAlreadyDeletedInSession(DocId, counter); } if (Session.DeferredCommandsDictionary.TryGetValue((DocId, CommandType.Counters, null), out var command)) { var countersBatchCommandData = (CountersBatchCommandData)command; if (countersBatchCommandData.HasDelete(counter)) { ThrowIncrementCounterAfterDeleteAttempt(DocId, counter); } countersBatchCommandData.Counters.Operations.Add(counterOp); }
public CountersBatchCommandData(string documentId, CounterOperation counterOperation) : this(documentId, new List <CounterOperation> { counterOperation }) { if (counterOperation == null) { throw new ArgumentNullException(nameof(counterOperation)); } }
public int Add(string id, CounterOperation op, out bool isNew) { isNew = false; if (_dictionary.TryGetValue(id, out var existing) == false) { isNew = true; _dictionary[id] = new List<CounterOperation> { op }; return 1; } existing.Add(op); return existing.Count; }
private void AddToBatch(CounterDetail counter) { var counterOp = new CounterOperation { Type = CounterOperationType.Put, CounterName = counter.CounterName, Delta = counter.TotalValue, ChangeVector = counter.ChangeVector }; _cmd.Add(counter.DocumentId, counterOp); _batchSize++; }
public void Add(string id, CounterOperation op) { if (_dictionary.TryGetValue(id, out var existing) == false) { _dictionary[id] = new List <CounterOperation> { op }; } else { existing.Add(op); } }
private void AddToBatch(CounterDetail counter) { var counterOp = new CounterOperation { Type = CounterOperationType.Put, CounterName = counter.CounterName, Delta = counter.TotalValue, ChangeVector = counter.ChangeVector }; var countersCount = _cmd.Add(counter.DocumentId, counterOp, out var isNew); if (isNew) { _docCount++; } if (countersCount > _countersPerDoc) { _countersPerDoc = countersCount; } }
private static void ThrowInvalidBatchOperationType(CounterOperation operation) { throw new ArgumentOutOfRangeException($"Unknown value {operation.Type}"); }
public Task UpdateBadgeCounter(string employeeId, string existingBadgeType, CounterOperation couterOperation, int numberOfBadges) { throw new NotImplementedException(); }