/// <summary>
        /// Updates data from ProfileStoreViewModel to Json token.
        /// </summary>
        /// <param name="jToken">Json Token that needs to be updated.</param>
        /// <param name="profileStore">ProfileStore contain updated information.</param>
        private void UpdateTokenData(ref JObject jToken, ProfileStoreModel newProfileStore)
        {
            var updateProfile = JsonConvert.DeserializeObject <ProfileStoreModel>(jToken.ToString());

            MergeProfileStore(updateProfile, newProfileStore);
            jToken = JObject.FromObject(updateProfile);
        }
 /// <summary>
 /// Updates profile store data by another profile store.
 /// </summary>
 /// <param name="destination"></param>
 /// <param name="origin"></param>
 private void MergeProfileStore(ProfileStoreModel destination, ProfileStoreModel origin)
 {
     destination.Name           = origin.Name;
     destination.ProfileManager = origin.ProfileManager;
     destination.Scope          = origin.Scope;
     destination.Info           = origin.Info;
     destination.Payload        = string.IsNullOrEmpty(origin.JsonPayload) ? new Dictionary <string, string>() : JsonConvert.DeserializeObject <Dictionary <string, string> >(origin.JsonPayload);
 }
        async Task <ProfileStoreModel> IProfileStoreService.GetProfileById(string scope, Guid profileId)
        {
            var profileStoreModel = new ProfileStoreModel();
            var response          = await Request(HttpMethod.Get, $"{apiBaseUrl}/{profilesUrl}/{scope}/{profileId.ToString()}");

            var getProfile = await response.Content.ReadAsStringAsync();

            if (string.IsNullOrEmpty(getProfile))
            {
                profileStoreModel = new ProfileStoreModel();
            }
            else
            {
                profileStoreModel = MapToProfileStore(getProfile);
            }

            return(profileStoreModel);
        }
 /// <summary>
 /// Load all country for listing
 /// </summary>
 /// <param name="profileModel"></param>
 public void LoadCountry(ProfileStoreModel profileModel) => profileModel.CountryOptions = GetAllCountries();
        async Task IProfileStoreService.EditOrCreateProfile(string scope, ProfileStoreModel model)
        {
            var profileId = model.ProfileId == null?Guid.NewGuid().ToString() : model.ProfileId.ToString();

            await Request(HttpMethod.Put, $"{apiBaseUrl}/{profilesUrl}/{profileId}", JsonConvert.SerializeObject(model));
        }