public string SaveLinksForTeam(TeamLinksDto teamLinksDto)
        {
            using (ConsoleRepository)
            {
                // Check does Team Links exist
                var team = ConsoleRepository.Query<Team>(t => t.Links).FirstOrDefault(t => t.Id == teamLinksDto.TeamId);

                bool linksChanged = false;
                if (team != null)
                {
                    // Remove links that need to be removed
                    var currentTeamLinks = team.Links.Select(t => t.Id).ToList();
                    var linksToRemove = currentTeamLinks.Except(teamLinksDto.TeamLinksIdList).ToList();

                    foreach (var linkId in linksToRemove)
                    {
                        var linkToDelete = ConsoleRepository.Query<Link>().FirstOrDefault(l => l.Id == linkId);

                        if (linkToDelete != null && team.Links.Any(l => l.Equals(linkToDelete)))
                        {
                            team.Links.Remove(linkToDelete);
                            linksChanged = true;
                        }
                    }

                    // Add Links that need to be added
                    foreach (var linkId in teamLinksDto.TeamLinksIdList)
                    {
                        if (team.Links.Any(l => l.Id == linkId)) continue;
                        var linkToAdd = ConsoleRepository.Query<Link>().FirstOrDefault(l => l.Id == linkId);

                        team.Links.Add(linkToAdd);
                        linksChanged = true;
                    }

                    ConsoleRepository.SaveChanges();

                    if (linksChanged)
                        return "Saved Link(s) for Team";
                    else
                        return "Link(s) for Team have not changed";
                }
                else
                {
                    return "Save Links - Team does not Exist";
                }
            }
        }
        public ActionResult SaveLinksForTeam(TeamLinksDto teamLinksDto)
        {
            try
            {
                var result = AdminModuleManager.SaveLinksForTeam(teamLinksDto);

                return new JsonNetResult
                {
                    Data = result
                };
            }
			catch (Exception ex) // TODO: Remove
            {
                LogHandler.WriteLog(ex.ToString(), LogSeverity.Error, LogCategory.BusinessComponent);
                throw new HttpException(500, "Server Error");
            }
        }
        public void SaveLinksForTeam_LinksSame_Success()
        {
            // Assign
            var teamLinksIdList = new List<int> { 7, 8 };
            var teamLinksDto = new TeamLinksDto { TeamId = _testTeam.Id, TeamLinksIdList = teamLinksIdList };

            var expectedResultMessage = "Save Links - Team does not Exist";

            // Act
            var actualResultMessage = _adminModuleManager.SaveLinksForTeam(teamLinksDto);

            // Assert
            Assert.AreNotEqual(expectedResultMessage, actualResultMessage);
        }