public async Task <ActionResult> EditWebsite(ProfileEditWebsiteModel model) { if (!ModelState.IsValid) { return(View()); } try { var svcWebsiteData = new MUser_UpdateWebsite() { WebsiteUrl = model.WebsiteUrl }; await UserMicroService.UpdateWebsiteAsync(GetUserId(), svcWebsiteData); AddFeedbackMessage(Feedback.FeedbackMessageTypes.Informational, "Website changed."); return(RedirectToAction("Index")); } catch (ServiceException ex) { AddModelErrors(ex); return(View()); } }
public async Task UpdateWebsiteAsync(string userId, MUser_UpdateWebsite website) { using var log = BeginFunction(nameof(UserMicroService), nameof(UpdateWebsiteAsync), userId, website); try { //await Assert(SecurityPolicy.IsAuthorized, userId).ConfigureAwait(false); using var ctx = QuiltContextFactory.Create(); var dbUserProfile = ctx.GetUserProfile(userId); dbUserProfile.WebsiteUrl = website.WebsiteUrl; _ = await ctx.SaveChangesAsync().ConfigureAwait(false); } catch (Exception ex) { log.Exception(ex); throw; } }