public async Task <ActionResult> UpdateSelfAppraisal(EmployeeViewModels employeeViewModels)
        {
            var pcAssociate     = _pcAssocaiteDa.GetPCAssociate(employeeViewModels.PcAssociateViewModel.PCAssociatesId);
            var appraisalSeason = _appraisalProcessDa.GetAppraisalSeason(employeeViewModels.PcAssociateViewModel.AppraisalSeasonId);
            var name            = employeeViewModels.PcAssociateViewModel.AssociateDisplayName + " - SelfAppraisalForm - " + appraisalSeason.Name;
            var path            = await _fileService.UploadFile(employeeViewModels.SelfAppraisalDocument, name, appraisalSeason.Name);

            pcAssociate.SelfAppraisalDocumentUrl = path;
            _pcAssocaiteDa.EditPCAssociate(pcAssociate);
            return(RedirectToAction("Index"));
        }
        public async Task <ActionResult> UpdateSelfAppraisal(Guid feedbackFor, string feedbackForName, HttpPostedFileBase file, int pcAssociateId)
        {
            var pcAssociate     = _pcAssocaiteDa.GetPCAssociate(pcAssociateId);
            var appraisalSeason = _appraisalSeasonDa.GetActiveAppraisalSeason();
            var ext             = Path.GetExtension(file.FileName);
            var name            = $"[{appraisalSeason.Name}]-self-appraisal-for-[{feedbackForName}]{ext}";
            var path            = await _fileService.UploadFile(file, name, appraisalSeason.Name);

            pcAssociate.SelfAppraisalDocumentUrl = path;
            _pcAssocaiteDa.EditPCAssociate(pcAssociate);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 3
0
        public async Task <ActionResult> AddPeers(AssociatePeerSelectionModel peerSelectionModel, string addPeersButton)
        {
            var peers = peerSelectionModel.PeerViewModels.Where(p => p.IsSelected == true)
                        .Select(p => AutoMapper.Mapper.Map <Peer>(p)).ToList();

            if (peers.Any())
            {
                var pcAssociateId = peers.FirstOrDefault().PCAssociateId;
                var peersForGivenAssociateByPcAssociateId = _peersDa.GetPeersForGivenAssociateByPcAssociateId(pcAssociateId);
                _peersDa.RemovePeers(peersForGivenAssociateByPcAssociateId);
                if (addPeersButton == "Finalize Peers")
                {
                    var pcAssociate = _pcAssociatesDa.GetPCAssociate(pcAssociateId);
                    pcAssociate.PeerListFinalized = true;
                    _pcAssociatesDa.EditPCAssociate(pcAssociate);

                    #region mailNotification
                    {
                        var allAdUsers = _activeDirectoryUserDa.GetActiveDirectoryUsers().ToList()
                                         .Select(p => AutoMapper.Mapper.Map <User>(p)).ToList();
                        var allAdUsersDictionary = allAdUsers.ToList().ToDictionary(p => p.id);
                        var pc        = allAdUsersDictionary[_pcAssociatesDa.GetPCAssociate(pcAssociateId).PCUserId];
                        var associate =
                            allAdUsersDictionary[_pcAssociatesDa.GetPCAssociate(pcAssociateId).AssociateUserId];
                        var peerUsers = new List <User>();
                        peers.ForEach(p => peerUsers.Add(allAdUsersDictionary[p.PeerUserId]));
                        var activeAppraisalSeason = _appraisalSeasonDa.GetActiveAppraisalSeason();
                        _notificationService.SendMessageToAssociateOnPeerListFinalization(pc, associate, peerUsers);
                        _notificationService.SendMessageToPeersOnPeerListFinalization(pc, associate, peerUsers, activeAppraisalSeason.Name);
                    }
                    #endregion
                }
            }


            _peersDa.AddPeers(peers);
            return(RedirectToAction("Index", "Home"));
        }