public void Add(User entity) { if (_db.Users.Any(u => u.Username.Equals(entity.Username, StringComparison.OrdinalIgnoreCase))) { throw new ArgumentNullException(nameof(entity), "Username was already taken!"); } _db.Users.Add(entity); _db.SaveChanges(); }
public void Add(DbConnection entity) { _db.DbConnections.Add(entity); _db.Entry(entity.User).State = EntityState.Detached; _db.SaveChanges(); }