Ejemplo n.º 1
0
        public async Task <EditStudentDataAccountView> LoadDataForEditStudentAccount(string userName)
        {
            Student teacher = await _studentRepository.GetStudentByName(userName);

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

            EditStudentDataAccountView viewModel = _studentMapper.MapEditStudentModelsToEditViewModels(teacher);

            return(viewModel);
        }
Ejemplo n.º 2
0
        public EditStudentDataAccountView MapEditStudentModelsToEditViewModels(Student teacher)
        {
            var viewModel = new EditStudentDataAccountView();

            viewModel.Id          = teacher.Id;
            viewModel.FirstName   = teacher.FirstName;
            viewModel.LastName    = teacher.LastName;
            viewModel.MiddleName  = teacher.MiddleName;
            viewModel.PhoneNumber = teacher.PhoneNumber;
            viewModel.BirthDate   = teacher.BirthDate.ToString("yyyy");
            viewModel.Username    = teacher.UserName;
            viewModel.Email       = teacher.Email;
            viewModel.AddressLine = teacher.AddressLine;
            viewModel.CathedraId  = teacher.CompanyId;

            return(viewModel);
        }
Ejemplo n.º 3
0
        public async Task <IActionResult> EditStudentInformation(EditStudentInformationView viewModel)
        {
            try
            {
                await _adminService.EditStudentInformation(viewModel);

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

                EditStudentDataAccountView result = await _adminService.LoadDataForEditStudentAccount(viewModel.Username);

                return(View(viewName: "Students/EditStudentAccount", result));
            }
        }
Ejemplo n.º 4
0
        public async Task <IActionResult> EditStudentAccount(string userName)
        {
            EditStudentDataAccountView result = await _adminService.LoadDataForEditStudentAccount(userName);

            return(View(viewName: "Students/EditStudentAccount", result));
        }