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