コード例 #1
0
        public ActionResult AddNewBranch(AddBranchViewModel newBranch)
        {
            if (ModelState.IsValid)
            {
                Branch branch = _mapper.Map <Branch>(newBranch);
                branch.BranchIdentificator = _keyGenerator.GenerateNewId();

                _context.branchRepository.AddBranch(branch);

                #region EntityLogs

                var logInfoAddBranch = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addBranch"]);
                _logger.AddBranchLog(branch, logInfoAddBranch);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddBranch = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addBranch"], "Nazwa: " + branch.Name);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddBranch);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnBranch", "Branches", new { branchIdentificator = branch.BranchIdentificator, typeOfAction = "Add" }));
            }

            return(View(newBranch));
        }
コード例 #2
0
        public ActionResult AddNewCertificate(AddCertificateViewModel newCertificate)
        {
            if (ModelState.IsValid)
            {
                Certificate certificate = _mapper.Map <Certificate>(newCertificate);
                certificate.CertificateIdentificator = _keyGenerator.GenerateNewId();
                certificate.CertificateIndexer       = _keyGenerator.GenerateCertificateEntityIndexer(certificate.Name);

                _context.certificateRepository.AddCertificate(certificate);

                #region EntityLogs

                var logInfoAddCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addCertificate"]);
                _logger.AddCertificateLog(certificate, logInfoAddCertificate);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addCertificate"], "Indekser: " + certificate.CertificateIndexer);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddCertificate);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnCertificate", new { certificateIdentificator = certificate.CertificateIdentificator, TypeOfAction = "Add" }));
            }

            newCertificate.AvailableBranches = _context.branchRepository.GetBranchesAsSelectList().ToList();
            if (newCertificate.SelectedBranches == null)
            {
                newCertificate.SelectedBranches = new List <string>();
            }

            return(View(newCertificate));
        }
コード例 #3
0
        public ActionResult AddNewCompany(AddCompanyViewModel newCompany)
        {
            if (ModelState.IsValid)
            {
                Company company = _mapper.Map <Company>(newCompany);
                company.CompanyIdentificator = _keyGenerator.GenerateNewId();

                _context.companyRepository.AddCompany(company);

                #region EntityLogs

                var logInfoAddCompany = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addCompany"]);
                _logger.AddCompanyLog(company, logInfoAddCompany);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddCompany = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addCompany"], "Nazwa przedsiębiorstwa: " + company.CompanyName);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddCompany);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnCompany", new { companyIdentificator = company.CompanyIdentificator, TypeOfAction = "Add" }));
            }

            return(View(newCompany));
        }
コード例 #4
0
        public async Task <IActionResult> Register(RegisterViewModel model, string returnUrl = null)
        {
            ViewData["ReturnUrl"] = returnUrl;
            if (ModelState.IsValid)
            {
                var user = _mapper.Map <CertificationPlatformUser>(model);
                user.Id            = _keyGenerator.GenerateNewId();
                user.SecurityStamp = _keyGenerator.GenerateNewGuid();

                var result = await _userManager.CreateAsync(user, model.Password);

                if (!await _roleManager.RoleExistsAsync("Worker"))
                {
                    await _roleManager.CreateAsync(new CertificationPlatformUserRole("Worker"));
                }

                var addToRole = await _userManager.AddToRoleAsync(user, "Worker");

                if (result.Succeeded)
                {
                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.EmailConfirmationLink(user.Id, code, Request.Scheme);

                    var emailToSend = _emailSender.GenerateEmailMessage(model.Email, user.FirstName + " " + user.LastName, "register", callbackUrl);
                    await _emailSender.SendEmailAsync(emailToSend);

                    #region EntityLogs

                    var logInfoRegister = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["registerUser"]);
                    _logger.AddUserLog(user, logInfoRegister);

                    #endregion

                    #region PersonalUserLogs

                    var createdUser = _context.userRepository.GetUserById(user.Id);
                    _context.personalLogRepository.CreatePersonalUserLog(createdUser);

                    var logInfoPersonalRegister = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["registerUser"]);
                    _context.personalLogRepository.AddPersonalUserLog(createdUser.Id, logInfoPersonalRegister);

                    #endregion

                    return(RedirectToAction("Login", "Account", new { message = "Na Twój adres email została wysłana wiadomość z informacją dotyczącą potwierdzenia adresu email." }));
                }

                ModelState.AddModelError(string.Empty, "Użytkownik o podanym adresie email już widnieje w systemie.");
                AddErrors(result);
            }

            return(View(model));
        }
コード例 #5
0
        public ActionResult AddNewGivenCertificate(AddGivenCertificateViewModel newGivenCertificate)
        {
            if (ModelState.IsValid)
            {
                GivenCertificate givenCertificate = _mapper.Map <GivenCertificate>(newGivenCertificate);
                givenCertificate.GivenCertificateIdentificator = _keyGenerator.GenerateNewId();

                givenCertificate.Course = _context.courseRepository.GetCourseById(newGivenCertificate.SelectedCourse).CourseIdentificator;

                var certificate = _context.certificateRepository.GetCertificateById(newGivenCertificate.SelectedCertificate);
                givenCertificate.Certificate             = certificate.CertificateIdentificator;
                givenCertificate.GivenCertificateIndexer = _keyGenerator.GenerateGivenCertificateEntityIndexer(certificate.CertificateIndexer);

                _context.givenCertificateRepository.AddGivenCertificate(givenCertificate);
                _context.userRepository.AddUserCertificate(newGivenCertificate.SelectedUser, givenCertificate.GivenCertificateIdentificator);

                var user = _context.userRepository.GetUserById(newGivenCertificate.SelectedUser);

                #region EntityLogs

                var logInfoAddGivenCertificate = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addGivenCertificate"]);
                _logger.AddGivenCertificateLog(givenCertificate, logInfoAddGivenCertificate);

                var logInfoUpdateUser = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["addUserGivenCertificate"]);
                _logger.AddUserLog(user, logInfoUpdateUser);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddGivenCertificate = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addGivenCertificate"], "Indekser: " + givenCertificate.GivenCertificateIndexer);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddGivenCertificate);

                var logInfoPersonalAddGivenCertificateToUser = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addUserGivenCertificate"], "Indekser: " + givenCertificate.GivenCertificateIndexer);
                _context.personalLogRepository.AddPersonalUserLog(user.Id, logInfoPersonalAddGivenCertificateToUser);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnGivenCertificate", new { givenCertificateIdentificator = givenCertificate.GivenCertificateIdentificator, TypeOfAction = "Add" }));
            }

            newGivenCertificate.AvailableCertificates = _context.certificateRepository.GetCertificatesAsSelectList().ToList();
            newGivenCertificate.AvailableUsers        = _context.userRepository.GetUsersAsSelectList().ToList();
            newGivenCertificate.AvailableCourses      = _context.courseRepository.GetActiveCoursesAsSelectList().ToList();

            return(View(newGivenCertificate));
        }
コード例 #6
0
        public ActionResult AddNewMeeting(AddMeetingViewModel newMeeting)
        {
            if (ModelState.IsValid)
            {
                Meeting meeting = _mapper.Map <Meeting>(newMeeting);
                meeting.MeetingIdentificator = _keyGenerator.GenerateNewId();

                var course = _context.courseRepository.GetCourseById(newMeeting.SelectedCourse);
                meeting.MeetingIndexer = _keyGenerator.GenerateMeetingEntityIndexer(course.CourseIndexer);

                _context.meetingRepository.AddMeeting(meeting);
                _context.courseRepository.AddMeetingToCourse(meeting.MeetingIdentificator, newMeeting.SelectedCourse);

                #region EntityLogs

                var logInfoAddMeeting = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addMeeting"]);
                _logger.AddMeetingLog(meeting, logInfoAddMeeting);

                var updatedCourse = _context.courseRepository.GetCourseById(newMeeting.SelectedCourse);

                var logInfoUpdateCourse = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[1], LogDescriptions.DescriptionOfActionOnEntity["addMeeting"]);
                _logger.AddCourseLog(updatedCourse, logInfoUpdateCourse);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addMeeting"], "Indekser: " + meeting.MeetingIndexer);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddMeeting);

                var logInfoPersonalAddMeetingToCourse = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addMeetingToCourse"], "Indekser: " + course.CourseIndexer);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddMeetingToCourse);

                var logInfoPersonalAddInstructorsToMeeting = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addInstructorToMeeting"], "Indekser: " + meeting.MeetingIndexer);
                _context.personalLogRepository.AddPersonalUsersLogs(meeting.Instructors, logInfoPersonalAddInstructorsToMeeting);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnMeeting", new { meetingIdentificator = meeting.MeetingIdentificator, TypeOfAction = "Add" }));
            }

            newMeeting.AvailableCourses     = _context.courseRepository.GetActiveCoursesAsSelectList().ToList();
            newMeeting.AvailableInstructors = _context.userRepository.GetInstructorsAsSelectList().ToList();

            return(View(newMeeting));
        }
コード例 #7
0
        public void AddUserLoginLog(UserLoginLogInformation logInfo)
        {
            var userLoginLog = new UserLoginLog
            {
                UserLoginLogIdentificator = _keyGenerator.GenerateNewId(),
                LogData = logInfo
            };

            _logRepository.AddUserLoginLog(userLoginLog);
        }