コード例 #1
0
        public async Task <IActionResult> AddUpdate()
        {
            var genders = await _optionManager.GetGenders();

            var teacherAddUpdateViewModel = new TeacherAddUpdateViewModel {
                Genders = genders
            };

            return(View(teacherAddUpdateViewModel));
        }
コード例 #2
0
        public async Task <IActionResult> AddUpdate(TeacherAddUpdateViewModel teacherAddUpdateViewModel)
        {
            var genders = await _optionManager.GetGenders();

            var teacherBlDto = _mapper.Map <TeacherBlDto>(teacherAddUpdateViewModel.Teacher);

            var teacherAddUpdateModel = new TeacherAddUpdateModel
            {
                Teacher = teacherBlDto
            };

            var result = await _teacherManager.Add(teacherAddUpdateModel);

            ModelState.FromSpec(result.SpecResult.FailedSpecifications);

            teacherAddUpdateViewModel.Teacher.Id = result.Data;
            teacherAddUpdateViewModel.Message    = result.Message;
            teacherAddUpdateViewModel.Genders    = genders;

            return(View(teacherAddUpdateViewModel));
        }