public async Task <CSSResponse> UpdateUserLanguagePreference(UserLanguageEmployeeIdDetails userLanguageEmployeeIdDetails, UpdateUserLanguagePreferenceDTO userLanguagePreference) { UserLanguagePreference userLanguage = await _repository.UserLanguage.GetUserLanguagePreference(userLanguageEmployeeIdDetails); if (userLanguage == null) { //return new CSSResponse(HttpStatusCode.NotFound); var languagePreferenceRequest = _mapper.Map <UserLanguagePreference>(new UserLanguagePreference { EmployeeId = userLanguageEmployeeIdDetails.EmployeeId, LanguagePreference = userLanguagePreference.LanguagePreference }); _repository.UserLanguage.CreateUserLanguagePreference(languagePreferenceRequest); await _repository.SaveAsync(); return(new CSSResponse(userLanguagePreference, HttpStatusCode.Created)); } var updateLanguagePreferenceRequest = _mapper.Map(userLanguagePreference, userLanguage); _repository.UserLanguage.UpdateUserLanguagePreference(updateLanguagePreferenceRequest); await _repository.SaveAsync(); return(new CSSResponse(HttpStatusCode.NoContent)); }
public async Task <CSSResponse> GetUserLanguagePreference(string employeeId) { var userLanguage = await _repository.UserLanguage.GetUserLanguagePreference(new UserLanguageEmployeeIdDetails { EmployeeId = employeeId }); if (userLanguage == null) { userLanguage = new UserLanguagePreference { EmployeeId = employeeId, LanguagePreference = "en" }; } var mappedUserLanguage = _mapper.Map <UserLanguagePreference>(userLanguage); return(new CSSResponse(mappedUserLanguage, HttpStatusCode.OK)); }