Ejemplo n.º 1
0
        public async Task AddStateTracking(ObjectStateDto dto)
        {
            var objectState = ObjectStateDto.Map(dto);
            await _dbContext.AddAsync(objectState);

            await _dbContext.SaveChangesAsync();
        }
Ejemplo n.º 2
0
        public async Task <StateFromTableDto> AddStateToTable(StateFromTableDto dto)
        {
            var(stateTable, state) = StateFromTableDto.Map(dto);
            state.Id = 0;
            using (TransactionScope ts = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                await _dbContext.AddAsync(state);

                await _dbContext.SaveChangesAsync();

                stateTable.StateId = state.Id;
                await _dbContext.AddAsync(stateTable);

                await _dbContext.SaveChangesAsync();

                ts.Complete();
            }
            return(StateFromTableDto.Map(stateTable));
        }