public async Task SaveTraderAsync(Trader trader) { var item = Mapping.Mapper.Map <TraderAdapter>(trader); TraderAdapter checkExist = await _traderAdapter.Find(x => x.Identifier.Equals(item.Identifier)).FirstOrDefaultAsync(); if (checkExist != null) { await _traderAdapter.ReplaceOneAsync(x => x.Identifier.Equals(item.Identifier), item); } else { await _traderAdapter.InsertOneAsync(item); } }
public async Task SaveTradersAsync(List <Trader> traders) { var items = Mapping.Mapper.Map <List <TraderAdapter> >(traders); foreach (var item in items) { TraderAdapter checkExist = await _traderAdapter.Find(x => x.Identifier.Equals(item.Identifier)).FirstOrDefaultAsync(); if (checkExist != null) { await _traderAdapter.ReplaceOneAsync(x => x.Identifier.Equals(item.Identifier), item); } else { await _traderAdapter.InsertOneAsync(item); } } }