Esempio n. 1
0
        private void Receier_SameLastNameHappend(object sender, CoincidenceOfTheSurnamesEventArgs eventArgs)
        {
            AllUsers = workJSON.Deserialized();
            string sameLastName = eventArgs.LastName;

            Console.WriteLine(sameLastName);
            Console.WriteLine($"Similar last name " + sameLastName + " has detected. Namesake is");
            List <User> listOfNamesakes = new List <User>();

            foreach (User u in AllUsers)
            {
                if (u.SecondName == sameLastName)
                {
                    u.VriteInformationToConsole();
                    listOfNamesakes.Add(u);
                }
            }
            workJSON.SerializedToListOfNamesakes(listOfNamesakes);
        }
Esempio n. 2
0
        /// <summary>
        /// This method add new user
        /// </summary>
        public void AddUser()
        {
            AllUsers = workJSON.Deserialized();
            UserRegistration createNewUser = new UserRegistration();
            User             newUser       = createNewUser.ReadNewUser();

            AllUsers.Add(newUser);
            bool namesakesFound = false;

            foreach (User u in AllUsers)
            {
                if (u.SecondName == newUser.SecondName)
                {
                    namesakesFound = true;
                }
            }
            if (namesakesFound == true)
            {
                CoincidenceOfTheSurnamesEventArgs args = new CoincidenceOfTheSurnamesEventArgs();
                args.LastName = newUser.SecondName;
                OnSameLastNamesHappened(args);
            }
            workJSON.Serialized(AllUsers);
        }
Esempio n. 3
0
 /// <summary>
 /// Invokes event SameLastNamesHappened.
 /// </summary>
 /// <param name="eventArgs">Event arguments.</param>
 public virtual void OnSameLastNamesHappened(CoincidenceOfTheSurnamesEventArgs eventArgs)
 {
     SameLastNamesHappened?.Invoke(this, eventArgs);
 }