Beispiel #1
0
        //Update
        public bool UpdateBadges(int oldBadgeID, Badges newBadge)
        {
            var    badges = badgeDictionary;
            Badges oldBadge;
            bool   containsKey;

            //Find
            if (badges.ContainsKey(oldBadgeID))
            {
                containsKey = true;
                badges.TryGetValue(oldBadgeID, out oldBadge);

                //Update
                if (containsKey == true)
                {
                    oldBadge.DoorNames   = newBadge.DoorNames;
                    oldBadge.NameOnBadge = newBadge.NameOnBadge;
                    badges[oldBadgeID]   = newBadge;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                containsKey = false;
                Console.WriteLine("There was no badge with that ID.");
                return(false);
            }
        }
Beispiel #2
0
 //Create
 public void AddBadges(int badgeID, Badges badges)
 {
     badgeDictionary.Add(badgeID, badges);
 }