コード例 #1
0
        public void AddGivenCertificateLog(GivenCertificate givenCertificate, LogInformation logInfo)
        {
            var givenCertificateLog = new GivenCertificateLog
            {
                GivenCertificateLogIdentificator = _keyGenerator.GenerateNewId(),
                AlteredEntity = givenCertificate,
                LogData       = logInfo
            };

            _logRepository.AddGivenCertificateLog(givenCertificateLog);
        }
コード例 #2
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));
        }
コード例 #3
0
        public void UpdateGivenCertificate(GivenCertificate givenCertificate)
        {
            var filter = Builders <GivenCertificate> .Filter.Eq(x => x.GivenCertificateIdentificator, givenCertificate.GivenCertificateIdentificator);

            var result = GetGivenCertificates().ReplaceOne(filter, givenCertificate);
        }
コード例 #4
0
 public void AddGivenCertificate(GivenCertificate givenCertificate)
 {
     GetGivenCertificates().InsertOne(givenCertificate);
 }