Ejemplo n.º 1
0
        }//logIn

        private static void SetCurrentUser(string username, UserDataFetcher UDF)
        {
            List <User>   users     = DataFetcher.GetUsersAsList();
            int           id        = UDF.GetId();
            List <string> interests = new List <string>();

            DataFetcher.GetInterestsOfCurrentUserAsList(interests, id);
            //if logged in with username
            if (InputValidator.ValidateUsername(username))
            {
                findUser();
            }
            else
            {
                System.Net.Mail.MailAddress email;
                string Email = username;
                //if logged in with email
                if (InputValidator.ValidateEmail(Email, out email))
                {
                    findUser();
                }
            }

            //find user in db with same id and set CurrentUser's fields
            void findUser()
            {
                for (var i = 0; i < users.Count; i++)
                {
                    if (id == users[i].id)
                    {
                        CurrentUser.SetUserInfo(users[i].name, users[i].id, users[i].karma, users[i].rating, users[i].profileInfo, interests);
                        break;
                    }
                }
            }
        }