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)); }