private async Task SaveProfile() { try { Profile profile; if (_profileid != -1) { profile = await ProfileService.GetProfileAsync(_profileid); } else { profile = new Profile(); } profile.SiteId = PageState.Site.SiteId; profile.Name = _name; profile.Title = _title; profile.Description = _description; profile.Category = _category; profile.ViewOrder = int.Parse(_vieworder); profile.MaxLength = int.Parse(_maxlength); profile.DefaultValue = _defaultvalue; profile.IsRequired = (_isrequired == null ? false : Boolean.Parse(_isrequired)); profile.IsPrivate = (_isprivate == null ? false : Boolean.Parse(_isprivate)); if (_profileid != -1) { profile = await ProfileService.UpdateProfileAsync(profile); } else { profile = await ProfileService.AddProfileAsync(profile); } await logger.LogInformation("Profile Saved {Profile}", profile); NavigationManager.NavigateTo(NavigateUrl()); } catch (Exception ex) { await logger.LogError(ex, "Error Saving Profile {ProfleId} {Error}", _profileid, ex.Message); AddModuleMessage("Error Saving Profile", MessageType.Error); } }