/// <summary> /// check if all data are correct and get user /// </summary> /// <returns></returns> public User GetUser() { if (!WasTCVerify) { throw new InvalidOperationException("Time Cockpit verifying was not successful"); } if (!WasGLogin) { throw new InvalidOperationException("Google Login was not successful"); } if (!WaSSetSetting) { throw new InvalidOperationException("Setting was not filled"); } //Check if new user with same Timecockpit credentials was added meanwhile set setting if (DataDatabase.ExistsUser(NewUser.Username)) { throw new InvalidOperationException("There is the same username in database! Time Cockpit username is unique parameter and therefore it cannot be use more than once."); } NewUser.GoogleEmail = GUtil.GetEmail(NewUser); Synchronization.SyncNow(); return(NewUser); }
/// <summary> /// Get google mail for the google mail /// </summary> /// <returns></returns> public string GetGoogleEmail() { string[] files = Directory.GetFiles(tempDir); var tokenNames = files.Where(f => f.Contains(ChangingUser.Username)); // if google acount was editted if (tokenNames.ToList().Count != 0) { return(GUtil.GetEmail(ChangingUser, tempDir)); } //if not else { return(GUtil.GetEmail(ChangingUser)); } }