Example #1
0
        public async Task InsertAsync(InternalOrder internalOrder)
        {
            var entity =
                new InternalOrderEntity(GetPartitionKey(internalOrder.CreatedDate), GetRowKey(internalOrder.Id));

            Mapper.Map(internalOrder, entity);

            await _storage.InsertAsync(entity);

            AzureIndex index = new AzureIndex(GetIndexPartitionKey(internalOrder.Id), GetIndexRowKey(internalOrder.Id),
                                              entity);

            await _indicesStorage.InsertAsync(index);
        }
Example #2
0
        public async Task <InternalOrder> GetByIdAsync(string internalOrderId)
        {
            AzureIndex index = await _indicesStorage.GetDataAsync(GetIndexPartitionKey(internalOrderId),
                                                                  GetIndexRowKey(internalOrderId));

            if (index == null)
            {
                return(null);
            }

            InternalOrderEntity entity = await _storage.GetDataAsync(index);

            return(Mapper.Map <InternalOrder>(entity));
        }
Example #3
0
        public async Task UpdateAsync(InternalOrder internalOrder)
        {
            AzureIndex index = await _indicesStorage.GetDataAsync(GetIndexPartitionKey(internalOrder.Id),
                                                                  GetIndexRowKey(internalOrder.Id));

            if (index == null)
            {
                throw new EntityNotFoundException();
            }

            InternalOrderEntity entity = await _storage.GetDataAsync(index);

            Mapper.Map(internalOrder, entity);

            await _storage.InsertOrReplaceAsync(entity);
        }