コード例 #1
0
        public ActionResult AddNewDegree()
        {
            AddDegreeViewModel newDegree = new AddDegreeViewModel
            {
                AvailableBranches     = _context.branchRepository.GetBranchesAsSelectList().ToList(),
                AvailableCertificates = _context.certificateRepository.GetCertificatesAsSelectList().ToList(),
                AvailableDegrees      = _context.degreeRepository.GetDegreesAsSelectList().ToList(),

                SelectedBranches = new List <string>()
            };

            return(View(newDegree));
        }
コード例 #2
0
        public ActionResult AddNewDegree(AddDegreeViewModel newDegree)
        {
            if (ModelState.IsValid)
            {
                Degree degree = _mapper.Map <Degree>(newDegree);
                degree.DegreeIdentificator = _keyGenerator.GenerateNewId();
                degree.DegreeIndexer       = _keyGenerator.GenerateDegreeEntityIndexer(degree.Name);

                if (degree.Conditions.Count != 0)
                {
                    degree.Conditions = newDegree.ConditionsList.Split(",").ToList();
                }

                _context.degreeRepository.AddDegree(degree);

                #region EntityLogs

                var logInfoAddDegree = _logger.GenerateLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogTypeOfAction.TypesOfActions[0], LogDescriptions.DescriptionOfActionOnEntity["addDegree"]);
                _logger.AddDegreeLog(degree, logInfoAddDegree);

                #endregion

                #region PersonalUserLogs

                var logInfoPersonalAddDegree = _context.personalLogRepository.GeneratePersonalLogInformation(this.User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), LogDescriptions.DescriptionOfPersonalUserLog["addDegree"], "Indekser: " + degree.DegreeIndexer);
                _context.personalLogRepository.AddPersonalUserLogToAdminGroup(logInfoPersonalAddDegree);

                #endregion

                return(RedirectToAction("ConfirmationOfActionOnDegree", new { degreeIdentificator = degree.DegreeIdentificator, TypeOfAction = "Add" }));
            }

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

            return(View(newDegree));
        }