private bool ExistsNullGuest()
        {
            List <string> candidateGuestNames = GetCandidateGuestNames();
            bool          result = candidateGuestNames.Any(guestName => SessionController.GetUserByName(guestName) is null);

            return(result);
        }
Exemplo n.º 2
0
 private void LogOnButton_Click(object sender, RoutedEventArgs e)
 {
     userNameProvided = textBoxUserNameProvided.Text;
     currentUser      = SessionController.GetUserByName(userNameProvided);
     if (IsExistingUser())
     {
         SessionController.CurrenUser = currentUser;
         MainWindow.Refresh();
     }
     else
     {
         ShowLogOnValidationMessage();
     }
 }
        private void AddInvalidGuestNamesToValidationMessages()
        {
            const string nameFormat = "- {0}";

            foreach (string name in this.GetCandidateGuestNames())
            {
                bool isOwnerUser       = name == sourceAppointment.Owner.Name;
                bool isNonExistentUser = SessionController.GetUserByName(name) == null;
                bool isInvalidGuest    = isOwnerUser | isNonExistentUser;
                if (isInvalidGuest)
                {
                    validationMessages.Add(string.Format(CultureInfo.CurrentCulture, nameFormat, name));
                }
            }
        }
        private bool IsOwnerInvited()
        {
            bool          result = false;
            List <string> candidateGuestNames = GetCandidateGuestNames();

            foreach (string name in candidateGuestNames)
            {
                User candidateGuest = SessionController.GetUserByName(name);
                bool isOwner        = sourceAppointment.IsOwner(candidateGuest);
                if (isOwner)
                {
                    result = true;
                    break;
                }
            }
            return(result);
        }
        private List <User> GetValidGuests()
        {
            List <User>   result = new List <User>();
            List <string> candidateGuestNames = GetCandidateGuestNames();

            foreach (string name in candidateGuestNames)
            {
                User candidateGuest = SessionController.GetUserByName(name);
                bool isNotOwner     = !sourceAppointment.IsOwner(candidateGuest);
                if (isNotOwner)
                {
                    result.Add(candidateGuest);
                }
            }

            return(result);
        }
        private void AddCollisionedGuestNamesToValidationMessages()
        {
            const string nameFormat = "- {0}";

            foreach (string name in this.GetCandidateGuestNames())
            {
                User guest          = SessionController.GetUserByName(name);
                bool isNotNullGuest = !(guest is null);
                if (isNotNullGuest)
                {
                    bool isNotOwner  = !sourceAppointment.IsOwner(guest);
                    bool isColliding = guest.HasAppointmentCollision(sourceAppointment);
                    if (isNotOwner & isColliding)
                    {
                        validationMessages.Add(string.Format(CultureInfo.CurrentCulture, nameFormat, name));
                    }
                }
            }
        }
Exemplo n.º 7
0
 public LogOnForm()
 {
     InitializeComponent();
     currentUser = SessionController.GetUserByName(userNameProvided);
 }