public ActionResult GivenCertificateDetails(string givenCertificateIdentificator)
        {
            var givenCertificate = _context.givenCertificateRepository.GetGivenCertificateById(givenCertificateIdentificator);
            var certificate      = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);

            var user      = _context.userRepository.GetUserByGivenCertificateId(givenCertificate.GivenCertificateIdentificator);
            var companies = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager.Concat(user.CompanyRoleWorker).Distinct().ToList());

            var course   = _context.courseRepository.GetCourseById(givenCertificate.Course);
            var meetings = _context.meetingRepository.GetMeetingsById(course.Meetings);

            List <string> instructorsIdentificators = new List <string>();

            meetings.ToList().ForEach(z => z.Instructors.ToList().ForEach(s => instructorsIdentificators.Add(s)));
            instructorsIdentificators.Distinct();

            var instructors = _context.userRepository.GetInstructorsById(instructorsIdentificators);

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

            courseViewModel.Branches = _context.branchRepository.GetBranchesById(courseViewModel.Branches);

            List <DisplayMeetingWithoutCourseViewModel> meetingsViewModel = new List <DisplayMeetingWithoutCourseViewModel>();

            foreach (var meeting in meetings)
            {
                DisplayMeetingWithoutCourseViewModel singleMeeting = _mapper.Map <DisplayMeetingWithoutCourseViewModel>(meeting);
                singleMeeting.Instructors = _mapper.Map <List <DisplayCrucialDataUserViewModel> >(instructors.Where(z => meeting.Instructors.Contains(z.Id)).ToList());

                meetingsViewModel.Add(singleMeeting);
            }

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

            DisplayAllUserInformationViewModel userViewModel = _mapper.Map <DisplayAllUserInformationViewModel>(user);

            userViewModel.Roles = _context.userRepository.TranslateRoles(userViewModel.Roles);

            List <DisplayCrucialDataWithContactUserViewModel> instructorsViewModel = _mapper.Map <List <DisplayCrucialDataWithContactUserViewModel> >(instructors);

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

            certificateViewModel.Branches = _context.branchRepository.GetBranchesById(certificateViewModel.Branches);

            GivenCertificateDetailsViewModel verifiedGivenCertificate = new GivenCertificateDetailsViewModel();

            verifiedGivenCertificate.GivenCertificate             = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseExtendedViewModel>(givenCertificate);
            verifiedGivenCertificate.GivenCertificate.Certificate = certificateViewModel;

            verifiedGivenCertificate.Course   = courseViewModel;
            verifiedGivenCertificate.Meetings = meetingsViewModel;

            verifiedGivenCertificate.User        = userViewModel;
            verifiedGivenCertificate.Instructors = instructorsViewModel;
            verifiedGivenCertificate.Companies   = companiesViewModel;

            return(View(verifiedGivenCertificate));
        }
        public ActionResult WorkerGivenCertificateDetails(string givenCertificateIdentificator)
        {
            var givenCertificate = _context.givenCertificateRepository.GetGivenCertificateById(givenCertificateIdentificator);
            var certificate      = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);

            var course   = _context.courseRepository.GetCourseById(givenCertificate.Course);
            var meetings = _context.meetingRepository.GetMeetingsById(course.Meetings);

            List <string> instructorsIdentificators = new List <string>();

            meetings.ToList().ForEach(z => z.Instructors.ToList().ForEach(s => instructorsIdentificators.Add(s)));
            instructorsIdentificators.Distinct();

            var instructors = _context.userRepository.GetInstructorsById(instructorsIdentificators);

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

            courseViewModel.Branches = _context.branchRepository.GetBranchesById(courseViewModel.Branches);

            List <DisplayMeetingWithoutCourseViewModel> meetingsViewModel = new List <DisplayMeetingWithoutCourseViewModel>();

            foreach (var meeting in meetings)
            {
                DisplayMeetingWithoutCourseViewModel singleMeeting = _mapper.Map <DisplayMeetingWithoutCourseViewModel>(meeting);
                singleMeeting.Instructors = _mapper.Map <List <DisplayCrucialDataUserViewModel> >(instructors.Where(z => meeting.Instructors.Contains(z.Id)).ToList());

                meetingsViewModel.Add(singleMeeting);
            }

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

            certificateViewModel.Branches = _context.branchRepository.GetBranchesById(certificateViewModel.Branches);

            WorkerGivenCertificateDetailsViewModel givenCertificateDetails = new WorkerGivenCertificateDetailsViewModel();

            givenCertificateDetails.GivenCertificate             = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseExtendedViewModel>(givenCertificate);
            givenCertificateDetails.GivenCertificate.Certificate = certificateViewModel;

            givenCertificateDetails.Course   = courseViewModel;
            givenCertificateDetails.Meetings = meetingsViewModel;

            givenCertificateDetails.UserIdentificator = _context.userRepository.GetUserByGivenCertificateId(givenCertificateIdentificator).Id;

            if (this.User.IsInRole("Company"))
            {
                return(View("CompanyWorkerGivenCertificateDetails", givenCertificateDetails));
            }

            return(View(givenCertificateDetails));
        }
Exemple #3
0
        public ActionResult ConfirmationOfActionOnCertificate(string certificateIdentificator, string TypeOfAction)
        {
            if (certificateIdentificator != null)
            {
                ViewBag.TypeOfAction = TypeOfAction;

                var certificate = _context.certificateRepository.GetCertificateById(certificateIdentificator);
                DisplayCertificateViewModel modifiedCertificate = _mapper.Map <DisplayCertificateViewModel>(certificate);

                modifiedCertificate.Branches = _context.branchRepository.GetBranchesById(certificate.Branches);

                return(View(modifiedCertificate));
            }

            return(RedirectToAction(nameof(AddNewCertificate)));
        }
Exemple #4
0
        public ActionResult VerifyGivenCertificate(string givenCertificateIdentificator, bool anonymousVerification = true)
        {
            try
            {
                ObjectId.Parse(givenCertificateIdentificator);
            }
            catch (System.Exception)
            {
                return(BadRequest("Błędny format identyfikatora"));
            }

            var givenCertificate = _context.givenCertificateRepository.GetGivenCertificateById(givenCertificateIdentificator);

            if (givenCertificate != null)
            {
                var certificate = _context.certificateRepository.GetCertificateById(givenCertificate.Certificate);
                var user        = _context.userRepository.GetUserByGivenCertificateId(givenCertificate.GivenCertificateIdentificator);
                var companies   = _context.companyRepository.GetCompaniesById(user.CompanyRoleManager.Concat(user.CompanyRoleWorker).Distinct().ToList());

                if (anonymousVerification)
                {
                    List <DisplayCompanyViewModel> companiesViewModel                     = _mapper.Map <List <DisplayCompanyViewModel> >(companies);
                    DisplayCrucialDataWithBirthDateUserViewModel userViewModel            = _mapper.Map <DisplayCrucialDataWithBirthDateUserViewModel>(user);
                    DisplayCrucialDataCertificateViewModel       certificateViewModel     = _mapper.Map <DisplayCrucialDataCertificateViewModel>(certificate);
                    GivenCertificateDetailsForAnonymousViewModel verifiedGivenCertificate = new GivenCertificateDetailsForAnonymousViewModel();

                    verifiedGivenCertificate.GivenCertificate             = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseViewModel>(givenCertificate);
                    verifiedGivenCertificate.GivenCertificate.Certificate = certificateViewModel;
                    verifiedGivenCertificate.User      = userViewModel;
                    verifiedGivenCertificate.Companies = companiesViewModel;

                    return(Ok(verifiedGivenCertificate));
                }
                else
                {
                    var course   = _context.courseRepository.GetCourseById(givenCertificate.Course);
                    var meetings = _context.meetingRepository.GetMeetingsById(course.Meetings);

                    List <string> instructorsIdentificators = new List <string>();
                    meetings.ToList().ForEach(z => z.Instructors.ToList().ForEach(s => instructorsIdentificators.Add(s)));
                    instructorsIdentificators.Distinct();

                    var instructors = _context.userRepository.GetInstructorsById(instructorsIdentificators);

                    DisplayCourseViewModel courseViewModel = _mapper.Map <DisplayCourseViewModel>(course);
                    courseViewModel.Branches = _context.branchRepository.GetBranchesById(courseViewModel.Branches);

                    List <DisplayMeetingWithoutCourseViewModel> meetingsViewModel = new List <DisplayMeetingWithoutCourseViewModel>();

                    foreach (var meeting in meetings)
                    {
                        DisplayMeetingWithoutCourseViewModel singleMeeting = _mapper.Map <DisplayMeetingWithoutCourseViewModel>(meeting);
                        singleMeeting.Instructors = _mapper.Map <List <DisplayCrucialDataUserViewModel> >(instructors.Where(z => meeting.Instructors.Contains(z.Id)).ToList());

                        meetingsViewModel.Add(singleMeeting);
                    }

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

                    DisplayAllUserInformationViewModel userViewModel = _mapper.Map <DisplayAllUserInformationViewModel>(user);
                    userViewModel.Roles = _context.userRepository.TranslateRoles(userViewModel.Roles);

                    List <DisplayCrucialDataWithContactUserViewModel> instructorsViewModel = _mapper.Map <List <DisplayCrucialDataWithContactUserViewModel> >(instructors);

                    DisplayCertificateViewModel certificateViewModel = _mapper.Map <DisplayCertificateViewModel>(certificate);
                    certificateViewModel.Branches = _context.branchRepository.GetBranchesById(certificateViewModel.Branches);

                    GivenCertificateDetailsViewModel verifiedGivenCertificate = new GivenCertificateDetailsViewModel();
                    verifiedGivenCertificate.GivenCertificate             = _mapper.Map <DisplayGivenCertificateToUserWithoutCourseExtendedViewModel>(givenCertificate);
                    verifiedGivenCertificate.GivenCertificate.Certificate = certificateViewModel;

                    verifiedGivenCertificate.Course   = courseViewModel;
                    verifiedGivenCertificate.Meetings = meetingsViewModel;

                    verifiedGivenCertificate.User        = userViewModel;
                    verifiedGivenCertificate.Instructors = instructorsViewModel;
                    verifiedGivenCertificate.Companies   = companiesViewModel;

                    return(Ok(verifiedGivenCertificate));
                }
            }
            else
            {
                return(BadRequest("Certyfikat nie został odnaleziony"));
            }
        }
Exemple #5
0
        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));
        }