public static void UpdateCategory(string oldName, string newName) { var test = new DataServiceCollection <CategoryDto>(container.Category.ExecuteAsync().Result); test.Where(x => x.Id == oldName).FirstOrDefault().Name = newName; container.SaveChangesAsync(SaveChangesOptions.PostOnlySetProperties).Wait(); }
private void LinkExistingRuleGroups(ManagementService client, Action<LogInfo> logAction) { foreach (var linkedRuleGroup in this.relyingPartySpec.LinkedRuleGroups()) { var @group = linkedRuleGroup; DataServiceCollection<RuleGroup> ruleGroups = new DataServiceCollection<RuleGroup>(client.RuleGroups); while (ruleGroups.Continuation != null) { ruleGroups.Load(client.Execute<RuleGroup>(ruleGroups.Continuation)); } foreach (var ruleGroup in ruleGroups.Where(rg => System.Text.RegularExpressions.Regex.IsMatch(rg.Name, group))) { var relyingParty = client.RelyingParties.Where(rp => rp.Name.Equals(this.relyingPartySpec.Name())).Single(); var relyingPartyRuleGroup = new RelyingPartyRuleGroup { RuleGroupId = ruleGroup.Id, RelyingParty = relyingParty }; this.LogMessage(logAction, string.Format("Linking Relying Party '{0}' to Rule Group '{1}'", this.relyingPartySpec.Name(), ruleGroup.Name)); client.AddRelatedObject(relyingParty, "RelyingPartyRuleGroups", relyingPartyRuleGroup); } } if (this.relyingPartySpec.LinkedRuleGroups().Any()) { client.SaveChanges(SaveChangesOptions.Batch); this.LogSavingChangesMessage(logAction); } }