public void AddOwner(IClient client) { if (!Owners.Contains(client)) { Owners.Add(client); } }
public string DescribeAccess(string repoName, string user, CachedPermission level) { var repo = Repos.SingleOrDefault(r => r.Name == repoName); if (repo == null) { return(null); } if (Owners.Contains(user)) { return("(Owner)"); } foreach (var repoAccess in repo.Teams) { if (repoAccess.Permission == level) { foreach (var team in repoAccess.Team.DescendentsAndSelf()) { if (team.Members.Contains(user)) { return(team.GetFullName()); } } } } return("(Collaborator)"); }
public async Task Save(PullRequestLocator prInfo, IRepoHistoryPersist persist) { if (!prInfo.IsValid()) { return; } var newPrInfo = new PullRequestLocator() { Owner = prInfo.Owner, Repository = prInfo.Repository, PullRequestNumber = prInfo.PullRequestNumber, }; if (PullRequests.Contains(prInfo)) { PullRequests.Remove(prInfo); } PullRequests.Insert(0, newPrInfo); if (!Owners.Contains(prInfo.Owner)) { Owners.Insert(0, prInfo.Owner); } if (!Repositories.Contains(prInfo.Repository)) { Repositories.Insert(0, prInfo.Repository); } await persist.Save(ToContainer()); }
public bool LogIn(string name, string password) { if (!string.IsNullOrEmpty(Password) && password == Password && !Owners.Contains(name)) { Owners.Add(name); return(true); } else { return(false); } }
public void RemoveOwner(ICustomer owner) { if (owner == null) { throw new ArgumentNullException("No owner specified"); } if (!Owners.Contains(owner)) { throw new ArgumentException("Owner not registered for bank account."); } owner.BankAccounts.Remove(this); Owners.Remove(owner); }
public void AddOwner(ICustomer owner) { if (owner == null) { throw new ArgumentNullException("No owner specified"); } if (Owners.Contains(owner)) { throw new ArgumentException("Owner already registered for bank account."); } Owners.Add(owner); owner.AddBankAccount(this); }
public override bool IsOwner(Mobile from) { if (from == null || from.Deleted || this.Deleted) { return(false); } if (from.AccessLevel > AccessLevel.GameMaster) { return(true); } return(Owners.Contains(from)); }
protected override async Task OnExecute() { // Gather default data SqlConnectionInfo connInfo; if (String.IsNullOrEmpty(DatabaseConnectionString)) { connInfo = await GetSqlConnectionInfo( 0, KnownSqlConnection.Legacy.ToString(), specifiedAdminUser : null, specifiedAdminPassword : null, promptForPassword : false); } else { connInfo = new SqlConnectionInfo( new SqlConnectionStringBuilder(DatabaseConnectionString), credential: null); } await Console.WriteInfoLine(Strings.Package_ReserveCommand_Reserving, String.Join(", ", Ids), String.Join(", ", Owners), connInfo.ConnectionString.DataSource); using (var connection = await connInfo.Connect()) { foreach (var id in Ids) { if (!WhatIf) { var result = (await connection.QueryAsync <int>(@" IF EXISTS (SELECT 0 FROM PackageRegistrations WHERE [Id] = @id) SELECT 0 ELSE BEGIN INSERT INTO PackageRegistrations([Id], [DownloadCount]) VALUES(@id, 0) SELECT 1 END", new { id })).Single(); if (result == 0) { var existingOwners = await connection.QueryAsync <string>(@" SELECT u.Username FROM PackageRegistrations pr INNER JOIN PackageRegistrationOwners pro ON pro.PackageRegistrationKey = pr.[Key] INNER JOIN [Users] u ON u.[Key] = pro.UserKey WHERE pr.[Id] = @id ORDER BY u.Username", new { id }); // If we're in quiet mode, only show errors for packages owned by users not in the target if (existingOwners.Any(o => !Owners.Contains(o))) { await Console.WriteErrorLine( Strings.Package_ReserveCommand_IdAlreadyExists, id); foreach (string owner in existingOwners) { await Console.WriteInfoLine(Strings.Package_ReserveCommand_ExistingOwner, owner); } } } } foreach (var owner in Owners) { if (!WhatIf) { var result = (await connection.QueryAsync <int>(@" DECLARE @prKey int = (SELECT [Key] FROM PackageRegistrations WHERE Id = @id) DECLARE @uKey int = (SELECT [Key] FROM Users WHERE Username = @owner) IF EXISTS (SELECT 0 FROM PackageRegistrationOwners WHERE PackageRegistrationKey = @prKey AND UserKey = @uKey) SELECT 0 ELSE BEGIN INSERT INTO PackageRegistrationOwners([PackageRegistrationKey], [UserKey]) VALUES(@prKey, @uKey) SELECT 1 END", new { id, owner })).Single(); if (result == 0) { await Console.WriteInfoLine(Strings.Package_ReserveCommand_OwnerAlreadyExists, owner, id); } } } } } }
public bool Allow(string name) { return(IsFree || Owners.Contains(name)); }