示例#1
0
        private async Task SetInvoiceNumberInDictionaryAsync(IReliableStateManagerReplica stateManager, string yearKey, uint invoiceNumber)
        {
            var invoiceNumbersDictionary = await stateManager.GetOrAddAsync <IReliableDictionary <string, uint> >(InvoicesService.InvoiceNumbersDictionaryKeyName);

            using (var tx = stateManager.CreateTransaction())
            {
                await invoiceNumbersDictionary.AddAsync(tx, yearKey, invoiceNumber);

                await tx.CommitAsync();
            }
        }
示例#2
0
        private async Task <uint?> GetInvoiceNumberInDictionaryAsync(IReliableStateManagerReplica stateManager, string yearKey)
        {
            var invoiceNumbersDictionary = await stateManager.GetOrAddAsync <IReliableDictionary <string, uint> >(InvoicesService.InvoiceNumbersDictionaryKeyName);

            uint newInvoiceNumber = 0;

            using (var tx = stateManager.CreateTransaction())
            {
                var value = await invoiceNumbersDictionary.TryGetValueAsync(tx, yearKey);

                if (!value.HasValue)
                {
                    return(null);
                }
                newInvoiceNumber = value.Value;
            }
            return(newInvoiceNumber);
        }