Ejemplo n.º 1
0
        /// <summary>
        /// Uses the current category selection and creates a dictionary of recipients accordingly
        /// </summary>
        /// <param name="recipientsType">The category of recipients to use</param>
        /// <returns>An ObservableDictionary with all the relevent recipients (organized as <RecipientID, RecipientName>)</returns>
        private ObservableDictionary <int, string> CreateRecipientsList(EventRecipientsTypes recipientsType)
        {
            // Create a recipients dictioanry
            ObservableDictionary <int, string> recipients = new ObservableDictionary <int, string>();

            // Create the list of students
            switch (recipientsType)
            {
            case EventRecipientsTypes.Students:
                // Add every active student in the school
                _schoolData.Persons.Where(person => !person.User.isDisabled && person.isStudent).ToList()
                .ForEach(person => recipients.Add(person.personID, person.firstName + " " + person.lastName));
                break;

            case EventRecipientsTypes.Classes:
                // Add every class in the school
                _schoolData.Classes.ToList().ForEach(schoolClass => recipients.Add(schoolClass.classID, schoolClass.className));
                break;

            case EventRecipientsTypes.Everyone:
                recipients.Add(EVERYONE_OPTION, "כל בית הספר");
                break;

            default:
                throw new ArgumentException("Invalid recipient type!");
            }

            return(recipients);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates the AvailableSearchChoices list with the options per the search category
        /// </summary>
        private void UseSelectedSearchCategory(EventRecipientsTypes searchCategory)
        {
            AvailableSearchChoices = CreateRecipientsList(searchCategory);

            // Use the first choice in the AvailableSearchChoices dictioanry as the default choice
            if (AvailableSearchChoices.Count > 0)
            {
                SelectedSearchChoice = AvailableSearchChoices.First().Key;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Update the recipients list following a selection of recipients category
        /// </summary>
        /// <param name="recipientsType">The category of recipients to use</param>
        private void UpdateRecipientsList(EventRecipientsTypes recipientsType)
        {
            // Create the list of recipients for the current category selection
            Recipients = CreateRecipientsList(recipientsType);

            // Select first available recipient in the list (if it has any)
            SelectedRecipient = (Recipients.Count() > 0) ? Recipients.First().Key : NOT_ASSIGNED;

            // For some reason, after re-initializing the recipients list, the selection is not updated properly unless called again
            OnPropertyChanged("SelectedRecipient");
        }