Пример #1
0
        public ActionResult Create(UserViewModel viewModel)
        {
            UserRole role = viewModel.GetRole();
            int      id;

            if (role == UserRole.Doctor)
            {
                Doctor doctor = viewModel.GetDoctor();
                _doctorRepository.AddDoctor(doctor);

                id = doctor.DoctorId;
                _accountManagementService.CreateAccountForDoctor(id);
            }
            else
            {
                Staff staff = viewModel.GetStaff();
                _staffRepository.AddStaff(staff);

                id = staff.StaffId;
                _accountManagementService.CreateAccountForStaff(id, role);
            }

            return(RedirectToAction("Details", new { id, role, showUserCreatedAlert = true }));
        }