From 0c367790c50a2b66381db900f25747a3dc5ee91e Mon Sep 17 00:00:00 2001 From: connor-addison-h <70348761+connor-addison-h@users.noreply.github.com> Date: Thu, 30 May 2024 07:50:07 -0700 Subject: [PATCH] updated user service to include language code --- .../business/services/core/IUserService.java | 3 +++ .../business/services/system/UserService.java | 20 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/app/femr/business/services/core/IUserService.java b/app/femr/business/services/core/IUserService.java index 159a490ea..f08cf5cb9 100644 --- a/app/femr/business/services/core/IUserService.java +++ b/app/femr/business/services/core/IUserService.java @@ -85,6 +85,9 @@ public interface IUserService { */ ServiceResponse updateUser(UserItem userItem, String newPassword); + + ServiceResponse updateUserLanguageCode(UserItem userItem, String languageCode); + /** * Retrieves a user by their email address. TODO: stop returning data models * diff --git a/app/femr/business/services/system/UserService.java b/app/femr/business/services/system/UserService.java index 9f74d6600..f1ff567c7 100644 --- a/app/femr/business/services/system/UserService.java +++ b/app/femr/business/services/system/UserService.java @@ -249,6 +249,26 @@ public ServiceResponse updateUser(UserItem userItem, String newPasswor return response; } + @Override + public ServiceResponse updateUserLanguageCode(UserItem userItem, String languageCode) { + ServiceResponse response = new ServiceResponse<>(); + if (userItem == null) { + response.addError("", "send a user"); + return response; + } + + try { + IUser user = userRepository.retrieveUserById(userItem.getId()); + user.setLanguageCode(languageCode); + user = userRepository.updateUser(user); + response.setResponseObject(itemModelMapper.createUserItem(user)); + } catch (Exception ex) { + response.addError("", ex.getMessage()); + } + return response; + } + + /** * {@inheritDoc} */