// GET: Employee
        public async Task <ActionResult> Index()
        {
            var identityName = User.Identity.Name;
            var users        = _activeDirectoryUserDa.GetActiveDirectoryUsers().ToList()
                               .Select(p => AutoMapper.Mapper.Map <User>(p)).ToList();
            var adUsersMap = users.ToDictionary(key => key.id, value => value.displayName);
            var userID     = users.First(adUser => adUser.userPrincipalName == identityName).id;

            ViewBag.UserID      = userID;
            ViewBag.AssociateId = userID;
            var peersForGivenAssociate = _peersDa.GetAllPeersForGivenAssociate(userID);
            var employeeViewModels     = peersForGivenAssociate
                                         .Select(AutoMapper.Mapper.Map <EmployeeViewModel>)
                                         .ToList();
            var pcAssociateViewModel =
                AutoMapper.Mapper.Map <PCAssociateViewModel>(_pcAssocaiteDa.GetPCAssociateForGivenAssociateId(userID));

            pcAssociateViewModel.PCDisplayName              = adUsersMap[pcAssociateViewModel.PCUserId];
            pcAssociateViewModel.AssociateDisplayName       = adUsersMap[pcAssociateViewModel.PCUserId];
            employeeViewModels.ForEach(p => p.PeerName      = adUsersMap[p.PeerUserId]);
            employeeViewModels.ForEach(p => p.AssociateName = adUsersMap[p.AssociateUserId]);
            var viewModels = new EmployeeViewModels()
            {
                EmployeeModels       = employeeViewModels,
                PcAssociateViewModel = pcAssociateViewModel
            };

            return(View(viewModels));
        }
        /* public async Task<ActionResult> AssignAssociates(System.Guid pcID)
         * {
         *   var _userList = await _activeDirectory.GetAllAdUsers();
         *   ViewBag.PCId = pcID;
         *   //todo PCAssociate table may contain multiple entries for associate for multiple appraisal seasons
         *   var allPcAssociates = _pcAssociatesDa.GetAllPcAssociates().ToDictionary(k => k.AssociateUserId);
         *   List<PCAssociateUserViewModel> pcAssociateUsers = new List<PCAssociateUserViewModel>();
         *   _userList.ForEach(p => pcAssociateUsers.Add(new PCAssociateUserViewModel()
         *   {
         *       PCUserId = allPcAssociates.ContainsKey(p.id) ? allPcAssociates[p.id].PCUserId : Guid.Empty,
         *       AssociateUserId = p.id,
         *       AssociateDisplayName = p.displayName
         *   }));
         *   var pcAssociateUserViewModels = pcAssociateUsers
         *       .Where(p => (p.PCUserId == pcID || p.PCUserId == Guid.Empty) && (p.AssociateUserId != pcID)).ToList();
         *   return View(pcAssociateUserViewModels);
         * }
         *
         * public ActionResult MakeAssociate(Guid associateId, Guid pcId)
         * {
         *   SLAP_Data.PCAssociate pcAssociate = new SLAP_Data.PCAssociate()
         *   {
         *       PCUserId = pcId,
         *       AssociateUserId = associateId
         *   };
         *
         *   _pcAssociatesDa.AddAsociate(pcAssociate);
         *
         *   _notificationService.SendMessageToAssociateOnPcAssignment(
         *       new User {displayName = "Associate Name", mail = "*****@*****.**"},
         *       new User {displayName = "PC Name", mail = "*****@*****.**"});
         *
         *   return RedirectToAction("AssignAssociates", new {pcID = pcId});
         * }
         *
         * public ActionResult RemoveAssociate(Guid associateId, Guid pcId)
         * {
         *   _pcAssociatesDa.RemoveAssociate(associateId, pcId);
         *   return RedirectToAction("AssignAssociates", new {pcID = pcId});
         * }*/

        #region newAssociatesScreen

        public ActionResult AssignAssociates(Guid?pcId)
        {
            if (_appraisalSeasonDa.GetActiveAppraisalSeason() != null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            var _userList = _activeDirectoryUserDa.GetActiveDirectoryUsers().ToList()
                            .Select(p => AutoMapper.Mapper.Map <User>(p)).ToList();

            ViewBag.PCId   = pcId;
            ViewBag.pcName = _userList.First(p => p.id == pcId).displayName;
            var pcAssociate         = _pcAssociatesDa.GetPCAssociateForGivenAssociateId((Guid)pcId);
            var pcAsoociatePcUserId = Guid.Empty;

            if (pcAssociate != null)
            {
                pcAsoociatePcUserId = pcAssociate.PCUserId;
            }
            var allPcAssociates = _pcAssociatesDa.GetAllPcAssociatesForInProgressAppraisalSeason().ToDictionary(k => k.AssociateUserId);
            List <PCAssociateUserViewModel> pcAssociateUsers = new List <PCAssociateUserViewModel>();

            _userList.ForEach(p => pcAssociateUsers.Add(new PCAssociateUserViewModel()
            {
                PCUserId             = allPcAssociates.ContainsKey(p.id) ? allPcAssociates[p.id].PCUserId : Guid.Empty,
                Selected             = allPcAssociates.ContainsKey(p.id),
                AssociateUserId      = p.id,
                AssociateDisplayName = p.displayName
            }));

            var pcAssociateUserViewModels = pcAssociateUsers
                                            .Where(p => (p.PCUserId == pcId || p.PCUserId == Guid.Empty) && (p.AssociateUserId != pcId) && (pcAsoociatePcUserId != p.AssociateUserId)).ToList();

            pcAssociateUserViewModels.ForEach(p => p.PCUserId = (Guid)pcId);
            AssociateSelectionViewModel associateSelectionViewModel = new AssociateSelectionViewModel();

            associateSelectionViewModel.PcAssociateUserViewModels = pcAssociateUserViewModels;
            return(View(associateSelectionViewModel));
        }
        public async Task <ActionResult> Index()
        {
            User loggedInUser = null;

            if (Session[SK_CURRENT_USER] == null)
            {
                var identityName = User.Identity.Name;
                loggedInUser = AutoMapper.Mapper.Map <User>(_activeDirectoryUserDa.GetActiveDirectoryUserByEmailId(identityName));
                if (loggedInUser != null)
                {
                    loggedInUser.IsAdmin = _userRolesDA.IsAdmin(loggedInUser.id);
                    loggedInUser.IsPC    = _userRolesDA.IsUserPC(loggedInUser.id);
                }
                Session[SK_CURRENT_USER] = loggedInUser;
            }
            else
            {
                loggedInUser = (User)Session[SK_CURRENT_USER];
            }
            ViewBag.LoggedInUser = loggedInUser;
            AppraisalSeason inProgressAppraisalSeason = _appraisalSeasonDa.GetInProgressAppraisalSeason();

            ViewBag.InProgressAppraisalSeason = AutoMapper.Mapper.Map <AppraisalSeasonViewModel>(inProgressAppraisalSeason);
            if (inProgressAppraisalSeason != null && inProgressAppraisalSeason.IsActive.GetValueOrDefault())
            {
                var users = _activeDirectoryUserDa.GetActiveDirectoryUsers().ToList()
                            .Select(p => AutoMapper.Mapper.Map <User>(p)).ToList();
                var adUsersMap = users.ToDictionary(key => key.id, value => value);
                var pcAssociateUserViewModels = _pcAssocaiteDa.GetAllAssociateForGivenPCForActiveAppraisalSeason(loggedInUser.id).Select(pcAssociate => AutoMapper.Mapper.Map <PCAssociate, PCAssociateViewModel>(pcAssociate)).ToList();
                pcAssociateUserViewModels.ForEach(p => p.AssociateDisplayName          = adUsersMap[p.AssociateUserId].displayName);
                pcAssociateUserViewModels.ForEach(p => p.Peers.ForEach(q => q.PeerName = adUsersMap[q.PeerUserId].displayName));
                ViewBag.PcAssociateUserViewModels = pcAssociateUserViewModels;
                loggedInUser.PCAssociateModel     = AutoMapper.Mapper.Map <PCAssociateViewModel>(_pcAssocaiteDa.GetPCAssociateForGivenAssociateId(loggedInUser.id));
                if (loggedInUser.PCAssociateModel != null)
                {
                    loggedInUser.PC = adUsersMap[loggedInUser.PCAssociateModel.PCUserId];
                }
                var seekingFeedbackFrom = _peersDa.GetPeersForGivenAssociate(loggedInUser.id);
                loggedInUser.SeekingFeedbackFrom = seekingFeedbackFrom.Count > 0 ? seekingFeedbackFrom.Select(x => AutoMapper.Mapper.Map <PeerViewModel>(x)).ToList() : null;
                InitUserData(loggedInUser.SeekingFeedbackFrom, adUsersMap);
                var SendingFeedbackTo = _peersDa.GetUsersWhomeGivenAssociateIsPeer(loggedInUser.id);
                loggedInUser.SendingFeedbackTo = SendingFeedbackTo.Count > 0 ? SendingFeedbackTo.Select(x => AutoMapper.Mapper.Map <PeerViewModel>(x)).ToList() : null;
                InitUserData(loggedInUser.SendingFeedbackTo, adUsersMap);
            }
            return(View());
        }