public async Task Write(StoreItems changes)
 {
     foreach (var change in changes)
     {
         var             entityKey = GetEntityKey(change.Key);
         var             storeItem = (IStoreItem)change.Value;
         StoreItemEntity entity    = new StoreItemEntity(entityKey, storeItem);
         if (entity.ETag == null || entity.ETag == "*")
         {
             var result = await this.Table.ExecuteAsync(TableOperation.InsertOrReplace(entity)).ConfigureAwait(false);
         }
         else if (entity.ETag.Length > 0)
         {
             var result = await this.Table.ExecuteAsync(TableOperation.Replace(entity)).ConfigureAwait(false);
         }
         else
         {
             throw new Exception("etag empty");
         }
     }
 }
示例#2
0
    public StoreItemViewModel MapToDto(StoreItemEntity entity)
    {
        var dto = new StoreItemViewModel(entity.Id, entity.Code, entity.Data);

        return(dto);
    }
 private async Task WhenUserCreateStoreItem(StoreItemEntity entity)
 {
     var json = JsonSerializer.Serialize(new {entity.Code, entity.Data});
     await HttpClientDriver.SendPostRequest(ApiResources.CreateStoreItem, json);
 }