Exemple #1
0
        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));
        }
Exemple #2
0
        public async Task <IActionResult> UpdateUserLanguagePreference(string employeeId, [FromBody] UpdateUserLanguagePreferenceDTO userLanguagePreference)
        {
            var result = await _userLanguageService.UpdateUserLanguagePreference(new UserLanguageEmployeeIdDetails { EmployeeId = employeeId }, userLanguagePreference);

            return(StatusCode((int)result.Code, result.Value));
        }