Example #1
0
        public ActionResult CreateAcademicPlan(AcademicPlanViewModel academicPlanViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var academicPlanDTO = new AcademicPlanDTO
                    {
                        GroupCode       = academicPlanViewModel.GroupCode,
                        NameOfSpecialty = academicPlanViewModel.NameOfSpecialty
                    };

                    academicPlanService.CreateAcademicPlan(academicPlanDTO);

                    TempData["message"] = string.Format("Учебный план был добавлен");

                    return(RedirectToAction("index"));
                }
            }
            catch (ValidationException ex)
            {
                ModelState.AddModelError(ex.Property, ex.Message);
            }

            return(View(academicPlanViewModel));
        }
        public void CreateAcademicPlan(AcademicPlanDTO academicPlanDTO)
        {
            if (academicPlanDTO == null)
            {
                throw new ValidationException("Введите данные", "");
            }
            AcademicPlan academicPlan = new AcademicPlan
            {
                GroupCode       = academicPlanDTO.GroupCode,
                NameOfSpecialty = academicPlanDTO.NameOfSpecialty
            };


            Database.AcademicPlans.Create(academicPlan);
            Database.Save();
        }