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

            var studentAddUpdateViewModel = new StudentAddUpdateViewModel {
                Genders = genders
            };

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

            var studentBlDto = _mapper.Map <StudentBlDto>(studentAddUpdateViewModel.Student);

            var studentAddUpdateModel = new StudentAddUpdateModel
            {
                Student = studentBlDto
            };

            var result = await _studentManager.Add(studentAddUpdateModel);

            ModelState.FromSpec(result.SpecResult.FailedSpecifications);

            studentAddUpdateViewModel.Student.Id = result.Data;
            studentAddUpdateViewModel.Message    = result.Message;
            studentAddUpdateViewModel.Genders    = genders;

            return(View(studentAddUpdateViewModel));
        }