Exemplo n.º 1
0
        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));
        }
Exemplo n.º 2
0
        public ActionResult CompanyUsersGivenCompetences()
        {
            var companyManager = _context.userRepository.GetUserByEmail(this.User.Identity.Name);
            var companyWorkers = _context.userRepository.GetUsersWorkersByCompanyId(companyManager.CompanyRoleManager.FirstOrDefault());

            var givenCertificates = _context.givenCertificateRepository.GetGivenCertificatesById(companyWorkers.SelectMany(z => z.GivenCertificates).ToList());
            var givenDegrees      = _context.givenDegreeRepository.GetGivenDegreesById(companyWorkers.SelectMany(z => z.GivenDegrees).ToList());

            List <DisplayGivenCertificateViewModel> listOfGivenCertificates = new List <DisplayGivenCertificateViewModel>();

            foreach (var givenCertificate in givenCertificates)
            {
                var course      = _context.courseRepository.GetCourseById(givenCertificate.Course);
                var certificate = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);
                var user        = companyWorkers.Where(z => z.GivenCertificates.Contains(givenCertificate.GivenCertificateIdentificator)).FirstOrDefault();

                DisplayCrucialDataCourseViewModel      courseViewModel      = _mapper.Map <DisplayCrucialDataCourseViewModel>(course);
                DisplayCrucialDataCertificateViewModel certificateViewModel = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate);
                DisplayCrucialDataUserViewModel        userViewModel        = _mapper.Map <DisplayCrucialDataUserViewModel>(user);

                DisplayGivenCertificateViewModel singleGivenCertificate = _mapper.Map <DisplayGivenCertificateViewModel>(givenCertificate);
                singleGivenCertificate.Certificate = certificateViewModel;
                singleGivenCertificate.Course      = courseViewModel;
                singleGivenCertificate.User        = userViewModel;

                listOfGivenCertificates.Add(singleGivenCertificate);
            }

            List <DisplayGivenDegreeViewModel> listOfGivenDegrees = new List <DisplayGivenDegreeViewModel>();

            foreach (var givenDegree in givenDegrees)
            {
                var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree);
                var user   = companyWorkers.Where(z => z.GivenDegrees.Contains(givenDegree.GivenDegreeIdentificator)).FirstOrDefault();

                DisplayCrucialDataDegreeViewModel degreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(degree);
                DisplayCrucialDataUserViewModel   userViewModel   = _mapper.Map <DisplayCrucialDataUserViewModel>(user);

                DisplayGivenDegreeViewModel singleGivenDegree = _mapper.Map <DisplayGivenDegreeViewModel>(givenDegree);
                singleGivenDegree.Degree = degreeViewModel;
                singleGivenDegree.User   = userViewModel;

                listOfGivenDegrees.Add(singleGivenDegree);
            }

            DisplayCompanyWorkersGivenCompetencesViewModel companyUsersCompetences = new DisplayCompanyWorkersGivenCompetencesViewModel
            {
                CompanyIdentificator = companyManager.CompanyRoleManager.FirstOrDefault(),

                GivenCertificates = listOfGivenCertificates,
                GivenDegrees      = listOfGivenDegrees
            };

            return(View(companyUsersCompetences));
        }
Exemplo n.º 3
0
        public ActionResult ConfirmationOfActionOnGivenDegree(string givenDegreeIdentificator, string TypeOfAction)
        {
            if (givenDegreeIdentificator != null)
            {
                ViewBag.TypeOfAction = TypeOfAction;

                var givenDegree = _context.givenDegreeRepository.GetGivenDegreeById(givenDegreeIdentificator);

                var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree);
                var user   = _context.userRepository.GetUserByGivenDegreeId(givenDegree.GivenDegreeIdentificator);

                DisplayCrucialDataUserViewModel   userViewModel   = _mapper.Map <DisplayCrucialDataUserViewModel>(user);
                DisplayCrucialDataDegreeViewModel degreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(degree);

                DisplayGivenDegreeViewModel modifiedGivenDegree = _mapper.Map <DisplayGivenDegreeViewModel>(givenDegree);
                modifiedGivenDegree.Degree = degreeViewModel;
                modifiedGivenDegree.User   = userViewModel;

                return(View(modifiedGivenDegree));
            }

            return(RedirectToAction(nameof(AddNewGivenDegree)));
        }
Exemplo n.º 4
0
        public ActionResult DisplayAllGivenDegrees(string message = null)
        {
            ViewBag.Message = message;

            var givenDegrees = _context.givenDegreeRepository.GetListOfGivenDegrees();
            List <DisplayGivenDegreeViewModel> listOfGivenDegrees = new List <DisplayGivenDegreeViewModel>();

            foreach (var givenDegree in givenDegrees)
            {
                var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree);
                var user   = _context.userRepository.GetUserByGivenDegreeId(givenDegree.GivenDegreeIdentificator);

                DisplayCrucialDataDegreeViewModel degreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(degree);
                DisplayCrucialDataUserViewModel   userViewModel   = _mapper.Map <DisplayCrucialDataUserViewModel>(user);

                DisplayGivenDegreeViewModel singleGivenDegree = _mapper.Map <DisplayGivenDegreeViewModel>(givenDegree);
                singleGivenDegree.Degree = degreeViewModel;
                singleGivenDegree.User   = userViewModel;

                listOfGivenDegrees.Add(singleGivenDegree);
            }

            return(View(listOfGivenDegrees));
        }
Exemplo n.º 5
0
        public ActionResult VerifyUserCompetences(string userIdentificator, bool anonymousVerification = true)
        {
            var user = _context.userRepository.GetUserById(userIdentificator);

            if (user != null)
            {
                var givenCertificates = _context.givenCertificateRepository.GetGivenCertificatesById(user.GivenCertificates);
                var givenDegrees      = _context.givenDegreeRepository.GetGivenDegreesById(user.GivenDegrees);

                var companiesRoleWorker  = _context.companyRepository.GetCompaniesById(user.CompanyRoleWorker);
                var companiesRoleManager = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager);

                List <Company> companies = companiesRoleWorker.ToList();

                foreach (var company in companiesRoleManager)
                {
                    if (companies.Where(z => z.CompanyIdentificator == company.CompanyIdentificator).Count() == 0)
                    {
                        companies.Add(company);
                    }
                }

                if (anonymousVerification)
                {
                    List <DisplayGivenCertificateToUserWithoutCourseViewModel> listOfGivenCertificates = new List <DisplayGivenCertificateToUserWithoutCourseViewModel>();

                    if (givenCertificates.Count != 0)
                    {
                        foreach (var givenCertificate in givenCertificates)
                        {
                            var certificate = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);

                            DisplayCrucialDataCertificateViewModel certificateViewModel = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate);

                            DisplayGivenCertificateToUserWithoutCourseViewModel singleGivenCertificate = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseViewModel>(givenCertificate);
                            singleGivenCertificate.Certificate = certificateViewModel;

                            listOfGivenCertificates.Add(singleGivenCertificate);
                        }
                    }

                    List <DisplayGivenDegreeToUserViewModel> listOfGivenDegrees = new List <DisplayGivenDegreeToUserViewModel>();

                    if (givenDegrees.Count != 0)
                    {
                        foreach (var givenDegree in givenDegrees)
                        {
                            var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree);

                            DisplayCrucialDataDegreeViewModel degreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(degree);

                            DisplayGivenDegreeToUserViewModel singleGivenDegree = _mapper.Map <DisplayGivenDegreeToUserViewModel>(givenDegree);
                            singleGivenDegree.Degree = degreeViewModel;

                            listOfGivenDegrees.Add(singleGivenDegree);
                        }
                    }

                    List <DisplayCompanyViewModel> ListOfCompanies = _mapper.Map <List <DisplayCompanyViewModel> >(companies);

                    UserDetailsForAnonymousViewModel verifiedUser = _mapper.Map <UserDetailsForAnonymousViewModel>(user);
                    verifiedUser.GivenCertificates = listOfGivenCertificates;
                    verifiedUser.GivenDegrees      = listOfGivenDegrees;
                    verifiedUser.Companies         = ListOfCompanies;

                    return(Ok(verifiedUser));
                }
                else
                {
                    var courses = _context.courseRepository.GetCoursesById(user.Courses);

                    List <DisplayCourseViewModel> listOfCourses = new List <DisplayCourseViewModel>();

                    if (courses.Count != 0)
                    {
                        foreach (var course in courses)
                        {
                            DisplayCourseViewModel singleCourse = _mapper.Map <DisplayCourseViewModel>(course);
                            singleCourse.Branches = _context.branchRepository.GetBranchesById(course.Branches);

                            listOfCourses.Add(singleCourse);
                        }
                    }

                    List <DisplayGivenCertificateToUserViewModel> listOfGivenCertificates = new List <DisplayGivenCertificateToUserViewModel>();

                    if (givenCertificates.Count != 0)
                    {
                        foreach (var givenCertificate in givenCertificates)
                        {
                            var course      = _context.courseRepository.GetCourseById(givenCertificate.Course);
                            var certificate = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);

                            DisplayCrucialDataCourseViewModel courseViewModel = _mapper.Map <DisplayCrucialDataCourseViewModel>(course);

                            DisplayCrucialDataCertificateViewModel certificateViewModel = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate);

                            DisplayGivenCertificateToUserViewModel singleGivenCertificate = _mapper.Map <DisplayGivenCertificateToUserViewModel>(givenCertificate);
                            singleGivenCertificate.Certificate = certificateViewModel;
                            singleGivenCertificate.Course      = courseViewModel;

                            listOfGivenCertificates.Add(singleGivenCertificate);
                        }
                    }

                    List <DisplayGivenDegreeToUserViewModel> listOfGivenDegrees = new List <DisplayGivenDegreeToUserViewModel>();

                    if (givenDegrees.Count != 0)
                    {
                        foreach (var givenDegree in givenDegrees)
                        {
                            var degree = _context.degreeRepository.GetDegreeById(givenDegree.Degree);

                            DisplayCrucialDataDegreeViewModel degreeViewModel = _mapper.Map <DisplayCrucialDataDegreeViewModel>(degree);

                            DisplayGivenDegreeToUserViewModel singleGivenDegree = _mapper.Map <DisplayGivenDegreeToUserViewModel>(givenDegree);
                            singleGivenDegree.Degree = degreeViewModel;

                            listOfGivenDegrees.Add(singleGivenDegree);
                        }
                    }

                    List <DisplayCompanyViewModel> listOfCompanies = _mapper.Map <List <DisplayCompanyViewModel> >(companies);

                    UserDetailsViewModel verifiedUser = _mapper.Map <UserDetailsViewModel>(user);
                    verifiedUser.Roles = _context.userRepository.TranslateRoles(verifiedUser.Roles);

                    verifiedUser.GivenCertificates = listOfGivenCertificates;
                    verifiedUser.GivenDegrees      = listOfGivenDegrees;
                    verifiedUser.Courses           = listOfCourses;
                    verifiedUser.Companies         = listOfCompanies;

                    return(Ok(verifiedUser));
                }
            }
            else
            {
                return(BadRequest("Użytkownik nie został odnaleziony"));
            }
        }
Exemplo n.º 6
0
        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"));
            }
        }