public IAccountSettings TestAccount(IAccountSettings accountnForTest) { TrelloAccountSettings accountForTestTrello = (TrelloAccountSettings)accountnForTest; TrelloAccountToken testToken = accountForTestTrello.Tokens.FirstOrDefault(); accountForTestTrello.Tokens.Clear(); _trello.Authorize(testToken.UserToken); try { accountForTestTrello.TestResult = true; accountForTestTrello.Source = Sources.Trello; var boards = _trello.Boards.ForMe(); foreach (var board in boards) { TrelloAccountToken newToken = new TrelloAccountToken(); newToken.BoardID = board.Id; newToken.TokenName = board.Name; newToken.UserToken = testToken.UserToken; newToken.DateCreation = DateTime.Now; accountForTestTrello.Tokens.Add(newToken); } } catch (Exception) { accountForTestTrello.TestResult = false; } return(accountForTestTrello); }
public bool Equals(IAccountSettings accountToCompare) { if (accountToCompare is TrelloAccountSettings) { TrelloAccountSettings trelloAccountToCompere = (TrelloAccountSettings)accountToCompare; return(this.ID == trelloAccountToCompere.ID && this.AccountVersion == trelloAccountToCompere.AccountVersion); } return(false); }
public IAdapter GetAdapter(IAccountSettings account) { TrelloAccountSettings accountForTestTrello = (TrelloAccountSettings)account; TrelloAccountToken Token = accountForTestTrello.Tokens.FirstOrDefault(); TrelloManager adapter = new TrelloManager(); adapter.UserToken = Token.UserToken; adapter.BoardID = Token.BoardID; adapter.MinUpdateTime = account.MinUpdateTime; adapter.adapterLastUpdate = DateTime.MinValue; adapter.TokenID = Token.TokenId; return(adapter); }
public IAccountSettings Convert(ServiceAccount serviceAccount) { TrelloAccountSettings target = new TrelloAccountSettings(); target.ID = serviceAccount.ServiceAccountId; target.Name = serviceAccount.ServiceAccountName; target.Source = serviceAccount.Source; target.TestResult = serviceAccount.TestResult; target.MinUpdateTime = serviceAccount.MinUpdateTime; target.AccountVersion = serviceAccount.AccountVersion; target.Tokens = new List <TrelloAccountToken>(); if (serviceAccount.Tokens.Count > 0) { foreach (Token token in serviceAccount.Tokens) { TrelloAccountToken targetToken = new TrelloAccountToken(); targetToken = (TrelloAccountToken)targetToken.Convert(token); target.Tokens.Add(targetToken); } } return(target); }
public ServiceAccount Convert(IAccountSettings serviceAccount) { ServiceAccount target = new ServiceAccount(); TrelloAccountSettings currentAccount = (TrelloAccountSettings)serviceAccount; target.ServiceAccountId = currentAccount.ID; target.ServiceAccountName = currentAccount.Name; target.Source = Sources.Trello; target.TestResult = currentAccount.TestResult; target.AccountVersion = currentAccount.AccountVersion; target.MinUpdateTime = currentAccount.MinUpdateTime; List <Token> tok = new List <Token>(); if (currentAccount.Tokens != null) { foreach (TrelloAccountToken token in currentAccount.Tokens) { Token localtok = token.Convert(token); tok.Add(localtok); } target.Tokens = tok.ToArray(); } return(target); }