private void AddHolds(ExistingProblem problem, CreateProblemRequest newProblem, IEnumerable <Hold> existingHolds, IEnumerable <HoldRule> existingHoldRules) { if (problem.Holds is null) { throw new ArgumentException("The problem must have holds.", nameof(problem)); } if (newProblem.Holds is null) { throw new ArgumentException("The problem must have holds.", nameof(newProblem)); } foreach (var hold in problem.Holds) { var newHold = new CreateHoldOnProblemRequest() { HoldId = existingHolds.First(existingHold => existingHold.Name == hold.Hold).Id, IsStandingStartHold = hold.IsStandingStartHold, ExistingHoldRuleIds = new List <int>(), NewHoldRules = new List <CreateHoldRuleRequest>() }; AddHoldRules(hold, newHold, existingHoldRules); newProblem.Holds.Add(newHold); } }
private void AddHoldRules(ExistingProblemHold hold, CreateHoldOnProblemRequest newHold, IEnumerable <HoldRule> existingHoldRules) { foreach (string rule in hold.Rules ?? new List <string>()) { var existingRule = existingHoldRules.First(holdRule => holdRule.Name == rule); newHold.ExistingHoldRuleIds = newHold.ExistingHoldRuleIds.Concat(new List <int>() { existingRule.Id }); } }