public async Task <Attachment> InsertAsync(Attachment entity) { using (var tran = await _context.Database.BeginTransactionAsync()) { try { var sim = await _context.SimCards.FirstOrDefaultAsync(x => x.Id == entity.SimCardId); sim.IsActive = 1; sim.UpdateBy = entity.UserId; sim.UpdateByUser = entity.UserName; sim.UpdateTime = DateTime.Now; _context.Entry(sim).State = EntityState.Modified; await _context.AddAsync(entity); await _logRepository.InsertAsync(entity); await _context.SaveChangesAsync(); await tran.CommitAsync(); return(await Task.FromResult(entity)); } catch (Exception ex) { await tran.RollbackAsync(); throw ex; } } }
public async Task <MobileOperatorPackage> InsertAsync(MobileOperatorPackage entity) { await _context.AddAsync(entity); await _context.SaveChangesAsync(); return(await Task.FromResult(entity)); }