public async Task <IMerchantGroup> CreateAsync(IMerchantGroup src) { MerchantGroupEntity entity = MerchantGroupEntity.ByOwner.Create(src); await _tableStorage.InsertThrowConflict(entity); AzureIndex index = MerchantGroupEntity.IndexById.Create(entity); await _groupIndexStorage.InsertThrowConflict(index); return(Mapper.Map <MerchantGroup>(entity)); }
public async Task <IMerchantGroup> GetAsync(string id) { AzureIndex index = await _groupIndexStorage.GetDataAsync( MerchantGroupEntity.IndexById.GeneratePartitionKey(id), MerchantGroupEntity.IndexById.GenerateRowKey()); if (index == null) { return(null); } MerchantGroupEntity entity = await _tableStorage.GetDataAsync(index); return(Mapper.Map <MerchantGroup>(entity)); }
public async Task UpdateAsync(IMerchantGroup src) { AzureIndex index = await _groupIndexStorage.GetDataAsync( MerchantGroupEntity.IndexById.GeneratePartitionKey(src.Id), MerchantGroupEntity.IndexById.GenerateRowKey()); if (index == null) { throw new KeyNotFoundException(); } MerchantGroupEntity updatedEntity = await _tableStorage.MergeAsync( MerchantGroupEntity.ByOwner.GeneratePartitionKey(index.PrimaryPartitionKey), MerchantGroupEntity.ByOwner.GenerateRowKey(index.PrimaryRowKey), entity => { if (src.DisplayName != null) { entity.DisplayName = src.DisplayName; } if (!string.IsNullOrEmpty(src.Merchants)) { entity.Merchants = src.Merchants; } entity.MerchantGroupUse = src.MerchantGroupUse; return(entity); }); if (updatedEntity == null) { throw new KeyNotFoundException(); } }