public async Task <IActionResult> AddPatientNote(int id)
        {
            var userId = GetLoggedInUserId();

            if (userId < 1)
            {
                _log.LogError($"Authentication failure. Could not extract User's Id from Claims Principal.");
                Alert("Failed to authorize current User access to the Patient Record", AlertType.danger);
                return(RedirectToAction("Details", "Patient", new { id = id }));
            }

            var medicalPractitioner = await _userAdminSvc.GetUserFullDetailsAsync(userId);

            if (medicalPractitioner == null)
            {
                _log.LogError($"Failed to load Medical Practitioner's account. \"Id\"={userId}");
                Alert("Failed to authorize current User access to the Patient Record", AlertType.danger);
                return(RedirectToAction("Details", "Patient", new { id = id }));
            }

            var newPatientNote = new PatientNoteDto()
            {
                PatientId                    = id,
                MedicalPractitionerId        = userId,
                MedicalPractitionerFirstname = medicalPractitioner.Firstname,
                MedicalPractitionerLastname  = medicalPractitioner.Lastname,
                MedicalPractitionerTitle     = medicalPractitioner.Title.ToString()
            };

            return(View(newPatientNote));
        }
Beispiel #2
0
        public async Task <IActionResult> EditUser(int id)
        {
            // load the user from the database
            var userFromDb = await _userAdminSvc.GetUserFullDetailsAsync(id).ConfigureAwait(false);

            var userDetailsViewModel = new UserDetailsViewModel(userFromDb);

            // if the requested user is not found, load the EditUser view
            if (userFromDb != null)
            {
                return(View(userDetailsViewModel));
            }

            // if the requested user is not found, return an error
            var message = $"Cannot find user for editing. \"Id\"={id}";

            _logger.LogError(message);
            Alert(message, AlertType.danger);
            return(RedirectToAction("Index", "UserAdmin"));
        }