Пример #1
0
        public static int MatchPair(WorkerUser user)
        {
            int id = 0;

            foreach (var u in listOfUsers)
            {
                if (user.UserID != u.UserID && user.LookingFor == u.Gender)
                {
                    id = u.UserID;
                    listOfUsers.Remove(user);
                    listOfUsers.Remove(u);
                    break;
                }
            }

            File.Delete(pathToUsers);


            XmlSerializer formatter = new XmlSerializer(typeof(List <WorkerUser>));

            try
            {
                using (FileStream fs = new FileStream(pathToUsers, FileMode.OpenOrCreate))
                {
                    formatter.Serialize(fs, listOfUsers);
                }
            }
            catch (Exception)
            {
            }

            return(id);
        }
Пример #2
0
        public static void AddUser(string[] user)
        {
            WorkerUser newUser = new WorkerUser();

            newUser.UserID      = Int32.Parse(user[0]);
            newUser.PersonalKey = new Guid(user[1]);
            newUser.Gender      = (user[2] == "Male") ?  gender.Male :  gender.Female;
            newUser.LookingFor  = (user[3] == "Male") ? gender.Male : gender.Female;

            listOfUsers.Add(newUser);
            CreateUser(newUser);
            currentUser = newUser;
        }
Пример #3
0
        public static bool CreateUser(WorkerUser addUser)
        {
            List <WorkerUser> Users = GetUsers();

            Users.Add(addUser);

            XmlSerializer formatter = new XmlSerializer(typeof(List <WorkerUser>));

            try
            {
                using (FileStream fs = new FileStream(pathToUsers, FileMode.OpenOrCreate))
                {
                    formatter.Serialize(fs, Users);
                }
                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }