public ActionResult WorkerGivenDegreeDetails(string givenDegreeIdentificator) { var user = _context.userRepository.GetUserByEmail(this.User.Identity.Name); var givenDegree = _context.givenDegreeRepository.GetGivenDegreeById(givenDegreeIdentificator); var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree); var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); DisplayDegreeWithoutRequirementsViewModel degreeViewModel = _mapper.Map <DisplayDegreeWithoutRequirementsViewModel>(degree); degreeViewModel.Branches = _context.branchRepository.GetBranchesById(degree.Branches); List <DisplayGivenCertificateToUserWithoutCourseViewModel> listOfRequiredCertificatesWithInstances = new List <DisplayGivenCertificateToUserWithoutCourseViewModel>(); var usersGivenCertificate = _context.givenCertificateRepository.GetGivenCertificatesById(user.GivenCertificates); if (requiredCertificates.Count != 0) { foreach (var certificate in requiredCertificates) { DisplayCrucialDataCertificateViewModel certificateViewModel = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate); var requiredGivenCertificate = usersGivenCertificate.Where(z => z.Certificate == certificate.CertificateIdentificator).FirstOrDefault(); DisplayGivenCertificateToUserWithoutCourseViewModel requiredCertificateWithInstance = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseViewModel>(requiredGivenCertificate); requiredCertificateWithInstance.Certificate = certificateViewModel; listOfRequiredCertificatesWithInstances.Add(requiredCertificateWithInstance); } } List <DisplayGivenDegreeToUserViewModel> listOfRequiredDegreesWithInstances = new List <DisplayGivenDegreeToUserViewModel>(); var usersGivenDegrees = _context.givenDegreeRepository.GetGivenDegreesById(user.GivenDegrees); if (requiredDegrees.Count != 0) { foreach (var requiredSingleDegree in requiredDegrees) { DisplayCrucialDataDegreeViewModel singleDegreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(requiredSingleDegree); var requiredGivenDegree = usersGivenDegrees.Where(z => z.Degree == degree.DegreeIdentificator).FirstOrDefault(); DisplayGivenDegreeToUserViewModel requiredDegreeWithInstance = _mapper.Map <DisplayGivenDegreeToUserViewModel>(singleDegreeViewModel); requiredDegreeWithInstance.Degree = singleDegreeViewModel; listOfRequiredDegreesWithInstances.Add(requiredDegreeWithInstance); } } WorkerGivenDegreeDetailsViewModel givenDegreeDetails = new WorkerGivenDegreeDetailsViewModel(); givenDegreeDetails.GivenDegree = _mapper.Map <DisplayGivenDegreeToUserExtendedViewModel>(givenDegree); givenDegreeDetails.GivenDegree.Degree = degreeViewModel; givenDegreeDetails.RequiredCertificatesWithGivenInstances = listOfRequiredCertificatesWithInstances; givenDegreeDetails.RequiredDegreesWithGivenInstances = listOfRequiredDegreesWithInstances; return(View(givenDegreeDetails)); }
public ActionResult AnonymouslyVerificationOfGivenDegree(string givenDegreeIdentificator) { var givenDegree = _context.givenDegreeRepository.GetGivenDegreeById(givenDegreeIdentificator); var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree); var user = _context.userRepository.GetUserByGivenDegreeId(givenDegreeIdentificator); var companies = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager.Concat(user.CompanyRoleWorker).Distinct().ToList()); DisplayDegreeWithoutRequirementsViewModel degreeViewModel = _mapper.Map <DisplayDegreeWithoutRequirementsViewModel>(degree); degreeViewModel.Branches = _context.branchRepository.GetBranchesById(degree.Branches); DisplayCrucialDataWithBirthDateUserViewModel userViewModel = _mapper.Map <DisplayCrucialDataWithBirthDateUserViewModel>(user); List <DisplayCompanyViewModel> companiesViewModel = _mapper.Map <List <DisplayCompanyViewModel> >(companies); GivenDegreeDetailsForAnonymousViewModel givenDegreeDetails = new GivenDegreeDetailsForAnonymousViewModel(); givenDegreeDetails.GivenDegree = _mapper.Map <DisplayGivenDegreeToUserExtendedViewModel>(givenDegree); givenDegreeDetails.GivenDegree.Degree = degreeViewModel; givenDegreeDetails.User = userViewModel; givenDegreeDetails.Companies = companiesViewModel; return(View(givenDegreeDetails)); }
public ActionResult VerifyGivenDegree(string givenDegreeIdentificator, bool anonymousVerification = true) { try { ObjectId.Parse(givenDegreeIdentificator); } catch (System.Exception) { return(BadRequest("Błędny format identyfikatora")); } var givenDegree = _context.givenDegreeRepository.GetGivenDegreeById(givenDegreeIdentificator); var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree); var user = _context.userRepository.GetUserByGivenDegreeId(givenDegreeIdentificator); var companies = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager.Concat(user.CompanyRoleWorker).Distinct().ToList()); if (givenDegree != null) { if (anonymousVerification) { DisplayDegreeWithoutRequirementsViewModel degreeViewModel = _mapper.Map <DisplayDegreeWithoutRequirementsViewModel>(degree); degreeViewModel.Branches = _context.branchRepository.GetBranchesById(degree.Branches); DisplayCrucialDataWithBirthDateUserViewModel userViewModel = _mapper.Map <DisplayCrucialDataWithBirthDateUserViewModel>(user); List <DisplayCompanyViewModel> companiesViewModel = _mapper.Map <List <DisplayCompanyViewModel> >(companies); GivenDegreeDetailsForAnonymousViewModel verifiedGivenDegree = new GivenDegreeDetailsForAnonymousViewModel(); verifiedGivenDegree.GivenDegree = _mapper.Map <DisplayGivenDegreeToUserExtendedViewModel>(givenDegree); verifiedGivenDegree.GivenDegree.Degree = degreeViewModel; verifiedGivenDegree.User = userViewModel; verifiedGivenDegree.Companies = companiesViewModel; return(Ok(verifiedGivenDegree)); } else { var requiredDegrees = _context.degreeRepository.GetDegreesById(degree.RequiredDegrees); var requiredCertificates = _context.certificateRepository.GetCertificatesById(degree.RequiredCertificates); DisplayDegreeWithoutRequirementsViewModel degreeViewModel = _mapper.Map <DisplayDegreeWithoutRequirementsViewModel>(degree); degreeViewModel.Branches = _context.branchRepository.GetBranchesById(degree.Branches); DisplayAllUserInformationViewModel userViewModel = _mapper.Map <DisplayAllUserInformationViewModel>(user); List <DisplayCompanyViewModel> companiesViewModel = _mapper.Map <List <DisplayCompanyViewModel> >(companies); List <DisplayGivenCertificateToUserWithoutCourseViewModel> listOfRequiredCertificatesWithInstances = new List <DisplayGivenCertificateToUserWithoutCourseViewModel>(); var UsersGivenCertificate = _context.givenCertificateRepository.GetGivenCertificatesById(user.GivenCertificates); if (requiredCertificates.Count != 0) { foreach (var certificate in requiredCertificates) { DisplayCrucialDataCertificateViewModel certificateViewModel = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate); var requiredGivenCertificate = UsersGivenCertificate.Where(z => z.Certificate == certificate.CertificateIdentificator).FirstOrDefault(); DisplayGivenCertificateToUserWithoutCourseViewModel requiredCertificateWithInstance = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseViewModel>(requiredGivenCertificate); requiredCertificateWithInstance.Certificate = certificateViewModel; listOfRequiredCertificatesWithInstances.Add(requiredCertificateWithInstance); } } List <DisplayGivenDegreeToUserViewModel> listOfRequiredDegreesWithInstances = new List <DisplayGivenDegreeToUserViewModel>(); var usersGivenDegrees = _context.givenDegreeRepository.GetGivenDegreesById(user.GivenDegrees); if (requiredDegrees.Count != 0) { foreach (var requiredSingleDegree in requiredDegrees) { DisplayCrucialDataDegreeViewModel singleDegreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(requiredSingleDegree); var requiredGivenDegree = usersGivenDegrees.Where(z => z.Degree == degree.DegreeIdentificator).FirstOrDefault(); DisplayGivenDegreeToUserViewModel requiredDegreeWithInstance = _mapper.Map <DisplayGivenDegreeToUserViewModel>(singleDegreeViewModel); requiredDegreeWithInstance.Degree = singleDegreeViewModel; listOfRequiredDegreesWithInstances.Add(requiredDegreeWithInstance); } } GivenDegreeDetailsViewModel verifiedGivenDegree = new GivenDegreeDetailsViewModel(); verifiedGivenDegree.GivenDegree = _mapper.Map <DisplayGivenDegreeToUserExtendedViewModel>(givenDegree); verifiedGivenDegree.GivenDegree.Degree = degreeViewModel; verifiedGivenDegree.User = userViewModel; verifiedGivenDegree.Companies = companiesViewModel; verifiedGivenDegree.RequiredCertificatesWithGivenInstances = listOfRequiredCertificatesWithInstances; verifiedGivenDegree.RequiredDegreesWithGivenInstances = listOfRequiredDegreesWithInstances; return(Ok(verifiedGivenDegree)); } } else { return(BadRequest("Stopień zawodowy nie został odnaleziony")); } }