public ActionResult CompanyDegreeDetails(string degreeIdentificator) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var companyWorkers = _context.userRepository.GetUsersWorkersByCompanyId(user.CompanyRoleManager.FirstOrDefault()); var degree = _context.degreeRepository.GetDegreeById(degreeIdentificator); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); var givenDegreesInstances = _context.givenDegreeRepository.GetGivenDegreesByIdOfDegree(degreeIdentificator).Select(z => z.GivenDegreeIdentificator).ToList(); var companyWorkersWithDegree = companyWorkers.Where(z => z.GivenDegrees.Any(x => givenDegreesInstances.Contains(x))).ToList(); List <DisplayCertificateViewModel> listOfCertificates = _mapper.Map <List <DisplayCertificateViewModel> >(requiredCertificates); listOfCertificates.ForEach(z => z.Branches = _context.branchRepository.GetBranchesById(z.Branches)); List <DisplayDegreeViewModel> listOfDegrees = new List <DisplayDegreeViewModel>(); if (requiredDegrees.Count != 0) { foreach (var requiredSingleDegree in requiredDegrees) { DisplayDegreeViewModel singleDegree = _mapper.Map <DisplayDegreeViewModel>(requiredSingleDegree); singleDegree.Branches = _context.branchRepository.GetBranchesById(requiredSingleDegree.Branches); singleDegree.RequiredCertificates = _context.degreeRepository.GetDegreesById(requiredSingleDegree.RequiredDegrees).Select(z => z.DegreeIndexer + " " + z.Name).ToList(); singleDegree.RequiredDegrees = _context.certificateRepository.GetCertificatesById(requiredSingleDegree.RequiredCertificates).Select(z => z.CertificateIndexer + " " + z.Name).ToList(); listOfDegrees.Add(singleDegree); } } CompanyDegreeDetailsViewModel degreeDetails = _mapper.Map <CompanyDegreeDetailsViewModel>(degree); degreeDetails.ConditionsList = String.Join(",", degree.Conditions); degreeDetails.Branches = _context.branchRepository.GetBranchesById(degree.Branches); degreeDetails.RequiredCertificates = listOfCertificates; degreeDetails.RequiredDegrees = listOfDegrees; degreeDetails.UsersWithDegree = _mapper.Map <List <DisplayCrucialDataUserViewModel> >(companyWorkersWithDegree); return(View(degreeDetails)); }
public ActionResult CompanyWorkersCompetences() { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var companyWorkers = _context.userRepository.GetUsersWorkersByCompanyId(user.CompanyRoleManager.FirstOrDefault()); var companyWorkersGivenCertificates = companyWorkers.SelectMany(z => z.GivenCertificates).ToList(); var companyWorkersCertificates = _context.givenCertificateRepository.GetGivenCertificatesById(companyWorkersGivenCertificates).Select(z => z.Certificate).Distinct().ToList(); var certificatesDetails = _context.certificateRepository.GetCertificatesById(companyWorkersCertificates); var companyWorkersGivenDegrees = companyWorkers.SelectMany(z => z.GivenDegrees).ToList(); var companyWorkersDegrees = _context.givenDegreeRepository.GetGivenDegreesById(companyWorkersGivenDegrees).Select(z => z.Degree).Distinct().ToList(); var degreesDetails = _context.degreeRepository.GetDegreesById(companyWorkersDegrees); List <DisplayDegreeViewModel> listOfDegrees = new List <DisplayDegreeViewModel>(); foreach (var degree in degreesDetails) { var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); DisplayDegreeViewModel singleDegree = _mapper.Map <DisplayDegreeViewModel>(degree); singleDegree.RequiredCertificates = requiredCertificates.Select(z => z.CertificateIndexer + " " + z.Name).ToList(); singleDegree.RequiredDegrees = requiredDegrees.Select(z => z.DegreeIndexer + " " + z.Name).ToList(); singleDegree.Branches = _context.branchRepository.GetBranchesById(degree.Branches); listOfDegrees.Add(singleDegree); } DisplayCompanyWorkersCompetencesViewModel companyWorkersCompetences = new DisplayCompanyWorkersCompetencesViewModel(); companyWorkersCompetences.Certificates = _mapper.Map <List <DisplayCertificateViewModel> >(certificatesDetails); companyWorkersCompetences.Certificates.ToList().ForEach(z => z.Branches = _context.branchRepository.GetBranchesById(z.Branches)); companyWorkersCompetences.Degrees = listOfDegrees; return(View(companyWorkersCompetences)); }
public ActionResult ConfirmationOfActionOnDegree(string degreeIdentificator, string TypeOfAction) { if (degreeIdentificator != null) { ViewBag.TypeOfAction = TypeOfAction; var degree = _context.degreeRepository.GetDegreeById(degreeIdentificator); var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); var branches = _context.branchRepository.GetBranchesById(degree.Branches); DisplayDegreeViewModel modifiedDegree = _mapper.Map <DisplayDegreeViewModel>(degree); modifiedDegree.RequiredCertificates = requiredCertificates.Select(z => z.CertificateIndexer + " " + z.Name).ToList(); modifiedDegree.RequiredDegrees = requiredDegrees.Select(z => z.DegreeIndexer + " " + z.Name).ToList(); modifiedDegree.Branches = branches; return(View(modifiedDegree)); } return(RedirectToAction(nameof(AddNewDegree))); }
public ActionResult DisplayAllDegrees(string message = null) { ViewBag.Message = message; var degrees = _context.degreeRepository.GetListOfDegrees(); List <DisplayDegreeViewModel> listOfDegrees = new List <DisplayDegreeViewModel>(); foreach (var degree in degrees) { var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); DisplayDegreeViewModel singleDegree = _mapper.Map <DisplayDegreeViewModel>(degree); singleDegree.RequiredCertificates = requiredCertificates.Select(z => z.CertificateIndexer + " " + z.Name).ToList(); singleDegree.RequiredDegrees = requiredDegrees.Select(z => z.DegreeIndexer + " " + z.Name).ToList(); singleDegree.Branches = _context.branchRepository.GetBranchesById(degree.Branches); listOfDegrees.Add(singleDegree); } return(View(listOfDegrees)); }
public ActionResult DegreeDetails(string degreeIdentificator) { var degree = _context.degreeRepository.GetDegreeById(degreeIdentificator); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); var givenDegreesInstances = _context.givenDegreeRepository.GetGivenDegreesByIdOfDegree(degreeIdentificator); var givenDegreesIdentificators = givenDegreesInstances.Select(z => z.GivenDegreeIdentificator); var usersWithDegree = _context.userRepository.GetUsersByDegreeId(givenDegreesIdentificators.ToList()); List <DisplayCertificateViewModel> listOfCertificates = new List <DisplayCertificateViewModel>(); if (requiredCertificates.Count != 0) { foreach (var certificate in requiredCertificates) { DisplayCertificateViewModel singleCertificate = _mapper.Map <DisplayCertificateViewModel>(certificate); singleCertificate.Branches = _context.branchRepository.GetBranchesById(certificate.Branches); listOfCertificates.Add(singleCertificate); } } List <DisplayDegreeViewModel> listOfDegrees = new List <DisplayDegreeViewModel>(); if (requiredDegrees.Count != 0) { foreach (var requiredSingleDegree in requiredDegrees) { DisplayDegreeViewModel singleDegree = _mapper.Map <DisplayDegreeViewModel>(requiredSingleDegree); singleDegree.Branches = _context.branchRepository.GetBranchesById(requiredSingleDegree.Branches); singleDegree.RequiredCertificates = _context.degreeRepository.GetDegreesById(requiredSingleDegree.RequiredDegrees).Select(z => z.DegreeIndexer + " " + z.Name).ToList(); singleDegree.RequiredDegrees = _context.certificateRepository.GetCertificatesById(requiredSingleDegree.RequiredCertificates).Select(z => z.CertificateIndexer + " " + z.Name).ToList(); listOfDegrees.Add(singleDegree); } } List <DisplayUserViewModel> listOfUsers = new List <DisplayUserViewModel>(); foreach (var user in usersWithDegree) { DisplayUserViewModel singleUser = _mapper.Map <DisplayUserViewModel>(user); singleUser.CompanyRoleManager = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager).Select(s => s.CompanyName).ToList(); singleUser.CompanyRoleWorker = _context.companyRepository.GetCompaniesById(user.CompanyRoleWorker).Select(s => s.CompanyName).ToList(); listOfUsers.Add(singleUser); } DegreeDetailsViewModel degreeDetails = _mapper.Map <DegreeDetailsViewModel>(degree); degreeDetails.ConditionsList = String.Join(",", degree.Conditions); degreeDetails.Branches = _context.branchRepository.GetBranchesById(degree.Branches); degreeDetails.RequiredCertificates = listOfCertificates; degreeDetails.RequiredDegrees = listOfDegrees; degreeDetails.UsersWithDegree = listOfUsers; return(View(degreeDetails)); }