public async Task AddAsync(Product product) { if (_context.Database.IsInMemory()) { await _context.Products.AddAsync(product); await _context.SaveChangesAsync(); return; } using (var transaction = await _context.Database.BeginTransactionAsync()) { await _context.Products.AddAsync(product); await _context.SaveChangesAsync(); transaction.Commit(); } }
public async Task <TblUser> Register(TblUser user, string password) { byte[] passwordHash, salt; CreatePasswordHash(password, out passwordHash, out salt); user.Password = passwordHash; user.Salt = salt; await _context.TblUser.AddAsync(user); await _context.SaveChangesAsync(); return(user); }