private void OnBuildStatusChanged(BuildStatusGroup oldStatus, BuildStatusGroup newStatus)
 {
     if (oldStatus != null)
     {
         // ToDo: implement proper update of bound viewmodel objects instead of creating new ones everytime
         newStatus.AdditionalInformationShown = oldStatus.AdditionalInformationShown;
     }
 }
        private List <BuildStatusGroup> GroupBuildsByDefinition(IEnumerable <IBuild> builds, ICollection <BuildStatusGroup> currentBuildsStatus)
        {
            currentBuildsStatus = currentBuildsStatus.Where(a => a.BuildDefinition != null).OrderBy(a => a.BuildDefinition.Name).ToList();

            var buildStatusGroups = new List <BuildStatusGroup>();
            var groupByDefinition = builds.GroupBy(a => a.Definition, build => build, this.buildDefinitionEqualityComparer);

            foreach (var grp in groupByDefinition)
            {
                var oldStatus = currentBuildsStatus.SingleOrDefault(a => this.buildDefinitionEqualityComparer.Equals(grp.Key, a.BuildDefinition));
                var newStatus = new BuildStatusGroup(grp.Key, grp.Select(a => new BuildItem(a, BuildViewStyle.GroupByBuildDefinition)).ToList());

                OnBuildStatusChanged(oldStatus, newStatus);

                buildStatusGroups.Add(newStatus);
            }

            return(buildStatusGroups);
        }
        private List <BuildStatusGroup> GroupBuildsByPullRequest(List <IBuild> builds, ICollection <BuildStatusGroup> currentBuildsStatus)
        {
            currentBuildsStatus = currentBuildsStatus.Where(a => a.PullRequest != null).OrderBy(a => a.PullRequest.Title).ToList();

            var buildStatusGroups = new List <BuildStatusGroup>();
            var groupByPr         = builds.GroupBy(a => a.PullRequest, build => build, this.pullRequstEqualityComparer);

            foreach (var grp in groupByPr)
            {
                var oldStatus = currentBuildsStatus.SingleOrDefault(a => this.pullRequstEqualityComparer.Equals(grp.Key, a.PullRequest));
                var newStatus = new BuildStatusGroup(grp.Key, grp.Select(a => new BuildItem(a, BuildViewStyle.GroupByPullRequest)).ToList());

                OnBuildStatusChanged(oldStatus, newStatus);

                buildStatusGroups.Add(newStatus);
            }

            return(buildStatusGroups);
        }