public async Task <ActionResult> EditTimeZone(ProfileEditTimeZoneModel model) { if (!ModelState.IsValid) { if (model.TimeZones == null) { model.TimeZones = GetTimeZones(string.IsNullOrEmpty(model.TimeZoneId)); } return(View(model)); } try { var svcTimeZoneData = new MUser_UpdateTimeZone() { TimeZoneId = model.TimeZoneId }; await UserMicroService.UpdateTimeZoneAsync(GetUserId(), svcTimeZoneData); UserLocale.RemoveFrom(HttpContext); AddFeedbackMessage(Feedback.FeedbackMessageTypes.Informational, "Timezone changed."); return(RedirectToAction("Index")); } catch (ServiceException ex) { AddModelErrors(ex); return(View()); } }
public async Task UpdateTimeZoneAsync(string userId, MUser_UpdateTimeZone timeZone) { using var log = BeginFunction(nameof(UserMicroService), nameof(UpdateTimeZoneAsync), userId, timeZone); try { //await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); using var ctx = QuiltContextFactory.Create(); var dbUserProfile = ctx.GetUserProfile(userId); dbUserProfile.TimeZoneId = timeZone.TimeZoneId; _ = await ctx.SaveChangesAsync().ConfigureAwait(false); } catch (Exception ex) { log.Exception(ex); throw; } }