Beispiel #1
0
        public async Task <IActionResult> EditTeacherInformation(EditTeacherInformationView viewModel)
        {
            try
            {
                await _adminService.EditTeacherInformation(viewModel);

                return(await EditTeacherAccount(viewModel.Username));
            }
            catch (BaseException ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);

                EditTeacherDataAccountView result = await _adminService.LoadDataForEditTeacherAccount(viewModel.Username);

                return(View(viewName: "Teachers/EditTeacherAccount", result));
            }
        }
Beispiel #2
0
        public async Task EditTeacherInformation(EditTeacherInformationView viewModel)
        {
            var user = await _userManager.FindByNameAsync(viewModel.Username) as Teacher;

            if (user is null)
            {
                throw new AdminException("User not found.");
            }

            user.FirstName   = viewModel.FirstName;
            user.LastName    = viewModel.LastName;
            user.MiddleName  = viewModel.MiddleName;
            user.PhoneNumber = viewModel.PhoneNumber;
            user.BirthDate   = _dateParseHelper.ParseStringToOnlyYearDatetime(viewModel.BirthDate).Value;

            user.AddressLine = viewModel.AddressLine;

            await _userManager.UpdateAsync(user);
        }