/// <summary>
        /// Assigns the severity and bug type severity list.
        /// </summary>
        /// <param name="bugType">Type of the bug.</param>
        /// <param name="bugItem">The bug item.</param>
        private static void AssignSeverityAndBugTypeSeverityList(IGrouping<string, ProjectPortalBugsBySeverityAndBugType> bugType, EnvironmentBugList bugItem)
        {
            var severityGroupedBugList = bugType.GroupBy(bugTypeItem => bugTypeItem.Severity);

            foreach (var severityItem in severityGroupedBugList)
            {
                var severityBug = new SeverityBug();

                severityBug.WorkItemCount = severityItem.Sum(bugTypeItem => bugTypeItem.WorkItemCount) ?? 0;

                switch (severityItem.Key)
                {
                    case SeverityCritical:
                        bugItem.CriticalBug = severityBug;
                        break;

                    case SeverityHigh:
                        bugItem.HighBug = severityBug;
                        break;

                    case SeverityMedium:
                        bugItem.MediumBug = severityBug;
                        break;

                    case SeverityLow:
                        bugItem.LowBug = severityBug;
                        break;
                }
            }
        }
        /// <summary>
        /// Assigns the environment and type list.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <param name="bugItem">The bug item.</param>
        private static void AssignEnvironmentAndTypeList(IGrouping<byte?, ProjectPortalBugsByEnvironmentAndBugType> environment, EnvironmentBugList bugItem)
        {
            var severityGroupedBugList = environment.GroupBy(bugType => bugType.BugType);

            foreach (var severity in severityGroupedBugList)
            {
                SeverityBug severityItem = new SeverityBug();

                severityItem.WorkItemCount = severity.Sum(bugType => bugType.WorkItemCount) ?? 0;

                switch (severity.Key)
                {
                    case CodeDefect:
                        bugItem.CodeDefect = severityItem;
                        break;

                    case SpecIssue:
                        bugItem.SpecIssue = severityItem;
                        break;

                    case Suggestion:
                        bugItem.Suggestion = severityItem;
                        break;
                }
            }
        }
        /// <summary>
        /// Assigns the type of the project portal bugs by severity and bug.
        /// </summary>
        /// <param name="projectPortalBugsBySeverityAndBugType">Type of the project portal bugs by severity and bug.</param>
        /// <returns>return the bugs by severity and bug type </returns>
        public ProjectDashboardPresenter AssignProjectPortalBugsBySeverityAndBugType(IList<ProjectPortalBugsBySeverityAndBugType> projectPortalBugsBySeverityAndBugType)
        {
            this.projectPortalBugsBySeverityAndBugTypeList = projectPortalBugsBySeverityAndBugType;
            var bugTypeGroupedBugList = projectPortalBugsBySeverityAndBugType.GroupBy(bug => bug.BugType);

            foreach (var bugType in bugTypeGroupedBugList)
            {
                var bugItem = new EnvironmentBugList();

                switch (bugType.Key)
                {
                    case Suggestion:
                        bugItem.Category = Suggestion;
                        break;

                    case CodeDefect:
                        bugItem.Category = CodeDefect;
                        break;

                    case SpecIssue:
                        bugItem.Category = SpecIssue;
                        break;
                }

                AssignSeverityAndBugTypeSeverityList(bugType, bugItem);
                this.bugsBySeverityAndBugTypeList.Add(bugItem);
            }

            return this;
        }
        /// <summary>
        /// Assigns the severity and environment severity list.
        /// </summary>
        /// <param name="environment">The environment.</param>
        /// <param name="bugItem">The bug item.</param>
        private static void AssignSeverityAndEnvironmentSeverityList(IGrouping<byte?, ProjectPortalBugsBySeverityAndEnvironment> environment, EnvironmentBugList bugItem)
        {
            var severityGroupedBugList = environment.GroupBy(bugType => bugType.Severity);

            foreach (var severity in severityGroupedBugList)
            {
                SeverityBug severityItem = new SeverityBug();

                severityItem.WorkItemCount = severity.Sum(bugType => bugType.WorkItemCount) ?? 0;

                switch (severity.Key)
                {
                    case SeverityCritical:
                        bugItem.CriticalBug = severityItem;
                        break;

                    case SeverityHigh:
                        bugItem.HighBug = severityItem;
                        break;

                    case SeverityMedium:
                        bugItem.MediumBug = severityItem;
                        break;

                    case SeverityLow:
                        bugItem.LowBug = severityItem;
                        break;
                }
            }
        }
        /// <summary>
        /// Assigns the type of the project portal bugs by environment and bug.
        /// </summary>
        /// <param name="projectPortalBugsByEnvironmentAndBugType">Type of the project portal bugs by environment and bug.</param>
        /// <returns>return project portal bugs and environment type</returns>
        public ProjectDashboardPresenter AssignProjectPortalBugsByEnvironmentAndBugType(IList<ProjectPortalBugsByEnvironmentAndBugType> projectPortalBugsByEnvironmentAndBugType)
        {
            this.projectPortalBugsByEnvironmentAndBugTypeList = projectPortalBugsByEnvironmentAndBugType;

            var environmentGroupedBugList = projectPortalBugsByEnvironmentAndBugType.GroupBy(bug => bug.Environment);

            foreach (var environment in environmentGroupedBugList)
            {
                EnvironmentBugList bugItem = new EnvironmentBugList();

                switch (environment.Key)
                {
                    case AllReleaseType:
                        bugItem.Category = InternalReleaseType;
                        break;

                    case PastReleaseType:
                        bugItem.Category = UatReleaseType;
                        break;

                    case FutureReleaseType:
                        bugItem.Category = ProductionReleaseType;
                        break;
                }

                AssignEnvironmentAndTypeList(environment, bugItem);

                this.bugsByEnvironmentAndTypeList.Add(bugItem);
            }

            return this;
        }