public async Task InsertAsync(ExternalTrade externalTrade) { using (DataContext context = _connectionFactory.CreateDataContext()) { ExternalTradeEntity entity = Mapper.Map <ExternalTradeEntity>(externalTrade); context.Add(entity); await context.SaveChangesAsync(); } }
public async Task <ExternalTrade> GetByIdAsync(string externalTradeId) { if (!Guid.TryParse(externalTradeId, out Guid id)) { throw new ArgumentException("Invalid identifier", nameof(externalTradeId)); } using (DataContext context = _connectionFactory.CreateDataContext()) { ExternalTradeEntity entity = await context.ExternalTrades.FirstOrDefaultAsync(o => o.Id == id); return(Mapper.Map <ExternalTrade>(entity)); } }