public async Task <object> UpdateUserCulture([FromBody] UpdateUserCultureOptions user) { if (user == null || string.IsNullOrWhiteSpace(user.CultureName)) { throw new ServiceException(Constants.UnsupportedCulture); } if (!this.localization.IsSupportedCulture(user.CultureName)) { throw new ServiceException(Constants.UnsupportedCulture); } string cultureName = user.CultureName; string timeZoneId = user.TimeZoneId; if (this.ApplicationUser() != null && this.ApplicationUser().UserId == user.UserId) { var dbUser = await this.profileService.UpdateUserCulture(user.UserId, user.CultureName, user.TimeZoneId); if (dbUser != null) { cultureName = dbUser.CultureName; timeZoneId = dbUser.TimeZoneId; } } var resources = await localization.ResolveCulture(cultureName); this.cultureService.RefreshCookie(this.HttpContext, user.CultureName, user.TimeZoneId); return(new { CultureName = cultureName, Resources = resources, TimeZoneId = timeZoneId }); }
public async Task <object> UpdateUserCulture([FromBody] UpdateUserCultureOptions user) { if (user == null || string.IsNullOrWhiteSpace(user.CultureName)) { this.ThrowLocalizedServiceException(Constants.UnknownUser); } if (!this.Localization.IsSupportedCulture(user.CultureName)) { this.ThrowLocalizedServiceException(Constants.UnknownCulture); } string cultureName = user.CultureName; string timeZoneId = user.TimeZoneId; Token? token = null; if (this.ApplicationUser() != null && this.ApplicationUser().UserId == user.UserId) { var identity = await this.profileService.UpdateUserCulture(user.UserId, user.CultureName, user.TimeZoneId); // if (identity != null) // token = await this.tokenService.IssueToken(identity, identity.Name); } var resources = await this.Localization.ResolveCulture(cultureName); this.cultureService.RefreshCookie(this.HttpContext, user.CultureName, user.TimeZoneId); return(new { CultureName = cultureName, Resources = resources, TimeZoneId = timeZoneId, Token = token }); }