예제 #1
0
        internal async Task<bool> Login(string email, string password)
        {
            List<User> selectedUsers = _usersList.Where(User => User.Email.Equals(email, StringComparison.CurrentCultureIgnoreCase) && User.HashedPassword.Equals(password)).ToList();

            if (selectedUsers != null && selectedUsers.Count > 0)
            {
                _currentUser = selectedUsers[0];
                return true;
            }
            return false;
        }
예제 #2
0
 internal async Task<bool> ConfirmConnection(User mentee, User mentor)
 {
     Connection connection = GetConnection(mentee, mentor);
     if (connection == null)
     {
         return false;
     }
     connection.ConnectionStatus = ConnectionStatus.Friends;
     await _connectionsTable.UpdateAsync(connection);
     return true;
 }
예제 #3
0
 internal Connection GetConnection(User mentee, User mentor)
 {
     foreach (Connection allConnections in _connectionsList)
     {
         if(allConnections.MenteeId == mentee.Id && allConnections.MentorId == mentor.Id)
         {
             return allConnections;
         }
     }
     return null;
 }
예제 #4
0
 internal async Task<bool> AddConnection(User mentee, User mentor)
 {
     if (GetConnection(mentee, mentor) != null)
     {
         return false;
     }
     Connection currentConnection = new Connection { MenteeId = mentee.Id, MentorId = mentor.Id, Id = Guid.NewGuid().ToString(), ConnectionStatus = ConnectionStatus.Friends };
     _connectionsList.Add(currentConnection);
     await _connectionsTable.InsertAsync(currentConnection);
     return true;
 }
예제 #5
0
        internal async Task<bool> Register(string firstName, string lastName, string email, string password, bool isMentor)
        {
            List<User> selectedUsers = _usersList.Where(User => User.Email.Equals(email, StringComparison.CurrentCultureIgnoreCase)).ToList();

            if (selectedUsers.Count == 0)
            {
                _currentUser = new User { FirstName = firstName, LastName = lastName, Email = email, HashedPassword = password, Id = Guid.NewGuid().ToString(), IsMentor = isMentor };
                _usersList.Add(_currentUser);
                await _usersTable.InsertAsync(_currentUser);
                return true;
            }
            return false;
        }
예제 #6
0
 internal async Task<bool> DeclineConnection(User mentee, User mentor)
 {
     Connection connection = GetConnection(mentee, mentor);
     if (connection == null)
     {
         return false;
     }
     await _connectionsTable.DeleteAsync(connection);
     return true;
 }
예제 #7
0
 internal List<Connection> GetAssociatedConnections(User person)
 {
     return _connectionsList.Where(Connection => person.IsMentor ? Connection.MentorId.Equals(person.Id) : Connection.MenteeId.Equals(person.Id)).ToList();
 }