Beispiel #1
0
        /// <summary>
        /// gets the previous bug in the chain
        /// </summary>
        /// <returns>NoPreviousBugException is thrown if no previous bug is found, else return object of type type Bug</returns>
        private DeveloperBug GetPreviousBug()
        {
            DeveloperBug previousBug = DeveloperBug.Get(PreviousBugID);

            //if bug
            if (PreviousBugID != 0 && previousBug != null)
            {
                return(previousBug);
            }
            else
            {
                throw new NoPreviousBugException(string.Format("no previous Bug. Bug by id {0} is the first bug in the chain", Id));
            }
        }
Beispiel #2
0
        /// <summary>
        /// gets All newer and older records of Bug
        /// </summary>
        /// <param name="developerBugID"> Bug from Chain of Developer bugs</param>
        /// <returns>List<DeveloperBug></returns>
        public static List <DeveloperBug> getBugHistory(long developerBugID)
        {
            List <DeveloperBug> developerBugs = new List <DeveloperBug>();

            List <DeveloperBug> nextDeveloperBugs = new List <DeveloperBug>();

            //gets bug which can be at top, middle or bottum of the chain
            DeveloperBug firstBug = DeveloperBug.Get(developerBugID);

            //checks to see if bug has previous
            Boolean hasPreviousBugID = (firstBug.PreviousBugID != 0);

            //checks to see if bug has next
            Boolean      hasNextBugID = (firstBug.NextBugId != 0);
            DeveloperBug nextBug      = firstBug;
            DeveloperBug PreviousBug  = firstBug;

            //if bug has next, add to bug list
            while (hasNextBugID)
            {
                nextBug = DeveloperBug.Get(nextBug.NextBugId);
                nextDeveloperBugs.Add(nextBug);
                hasNextBugID = (nextBug.NextBugId != 0);
            }

            //add next bugs in correct order
            developerBugs.AddRange(nextDeveloperBugs.Reverse <DeveloperBug>());
            developerBugs.Add(firstBug);

            //if has previous bug, add to bug list
            while (hasPreviousBugID)
            {
                PreviousBug = DeveloperBug.Get(PreviousBug.PreviousBugID);
                if (PreviousBug != null)
                {
                    developerBugs.Add(PreviousBug);
                    hasPreviousBugID = (PreviousBug.PreviousBugID != 0);
                }
                else
                {
                    hasPreviousBugID = false;
                }
            }



            return(developerBugs);
        }