Ejemplo n.º 1
0
        public async Task AcceptAsync(
            Guid id,
            string customerId,
            long nonce,
            string masterWalletAddress,
            OperationType type,
            string contextJson,
            DateTime createdAt,
            string transactionHash)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var operation = OperationEntity.Create(
                    id,
                    customerId,
                    masterWalletAddress,
                    nonce,
                    type,
                    contextJson,
                    createdAt,
                    transactionHash);
                await context.Operations.AddAsync(operation);

                var operationRequest = new OperationRequestEntity {
                    Id = id
                };
                context.OperationRequests.Remove(operationRequest);

                await context.SaveChangesAsync();
            }
        }
        public async Task <Guid> AddAsync(Guid id,
                                          string customerId,
                                          long nonce,
                                          string masterWalletAddress,
                                          OperationType type,
                                          string contextJson,
                                          DateTime createdAt,
                                          string transactionHash)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var operation = OperationEntity.Create(
                    id,
                    customerId,
                    masterWalletAddress,
                    nonce,
                    type,
                    contextJson,
                    createdAt,
                    transactionHash);

                await context.Operations.AddAsync(operation);

                await context.SaveChangesAsync();

                return(operation.Id);
            }
        }
Ejemplo n.º 3
0
        public async Task AcceptBatchAsync(IEnumerable <IOperationRequest> operationRequests, Dictionary <Guid, string> operationsHashesDict)
        {
            using (var context = _contextFactory.CreateDataContext())
            {
                var operations = operationRequests.Select(r => OperationEntity.Create(r, operationsHashesDict[r.Id]));
                await context.Operations.AddRangeAsync(operations);

                var requestsForRemoval = operationRequests.Select(r => new OperationRequestEntity {
                    Id = r.Id
                });
                context.OperationRequests.RemoveRange(requestsForRemoval);

                await context.SaveChangesAsync();
            }
        }