public async Task <IActionResult> PatchUser([FromBody] UpdateInformationRequest data) { var user = await _userService.UpdateInformationById(User.GetId(), data); if (user == null) { return(BadRequest("Failed To Update User")); } return(Ok(user)); }
public void CheckForUpdates() { using (var service = new UpdateInformationService.UpdateInformationService()) { service.Url = Settings.Default.UpdateInformationServiceUrl; var installedProduct = new Product { Name = ProductInformation.Component, Version = ProductInformation.Version.ToString(), VersionSuffix = ProductInformation.VersionSuffix, Edition = ProductInformation.Edition, Release = ProductInformation.Release }; try { var request = new UpdateInformationRequest { InstalledProduct = installedProduct }; UpdateInformationResult result = service.GetUpdateInformation(request); if (result == null) { throw new Exception("Bad data received from service."); } if (!IsValidComponent(result.InstalledProduct) || IsSameComponent(result.InstalledProduct, installedProduct)) { base.Context.DesktopWindow.ShowMessageBox(SR.MessageNoUpdate, MessageBoxActions.Ok); } else { var upgrade = result.InstalledProduct; string message = String.Format(SR.MessageUpdateAvailable, ToString(upgrade)); UpdateAvailableForm.Show(message, result.DownloadUrl); } } catch (Exception e) { Platform.Log(LogLevel.Warn, e, "The request for update information failed."); Context.DesktopWindow.ShowMessageBox(SR.MessageUpdateRequestFailed, MessageBoxActions.Ok); } } }
public async Task <User> UpdateInformationById(long id, UpdateInformationRequest data) { var user = await _userRepo.GetByIdAsNoTracking(id); if (user == null) { return(null); } if (data.Email != null && user.Email != data.Email) { if (await CheckEmail(data.Email)) { return(null); } } if (!string.IsNullOrWhiteSpace(data.FirstName)) { user.FirstName = data.FirstName; } if (!string.IsNullOrWhiteSpace(data.LastName)) { user.LastName = data.LastName; } if (!string.IsNullOrWhiteSpace(data.Email)) { user.UserName = data.Email; user.Email = data.Email; } if (!string.IsNullOrWhiteSpace(data.AvatarImagePath)) { user.AvatarImagePath = data.AvatarImagePath; } user.OptedInForEmails = data.OptedInForEmails; await _userRepo.UpdateAsync(user); return(user); }