Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
0
        public ActionResult AddNewCertificate()
        {
            AddCertificateViewModel newCertificate = new AddCertificateViewModel
            {
                AvailableBranches = _context.branchRepository.GetBranchesAsSelectList().ToList(),
                SelectedBranches  = new List <string>()
            };

            return(View(newCertificate));
        }
Ejemplo n.º 3
0
        public IActionResult AddCertificate(AddCertificateViewModel model)
        {
            if (ModelState.IsValid)
            {
                EmployeeCertificate newCertificate = new EmployeeCertificate
                {
                    EmployeeId = model.EmployeeId,
                    Name       = model.Name,
                    Provider   = model.Provider,

                    Date  = model.Date,
                    Notes = model.Notes
                };
                _employeeRepository.AddEmpCertificate(newCertificate);

                var successMessage = "Certificate Info Updated Successfully. Name: " + newCertificate.EmployeeId;
                TempData["successAlert"] = successMessage;
                // return RedirectToAction(successMessage,"");
                return(PartialView("_PartialMessage"));
            }
            return(View());
        }