|
@@ -235,6 +235,29 @@ namespace HyperCube.Models
|
|
if (SurveyItemOptions.Count > 0 && SurveyItemOptions.ContainsKey(optionID))
|
|
if (SurveyItemOptions.Count > 0 && SurveyItemOptions.ContainsKey(optionID))
|
|
{
|
|
{
|
|
Console.WriteLine($"Survey [{SurveyID}] Item [{ID}] MoveOption id:{SurveyItemOptions[optionID].ID}");
|
|
Console.WriteLine($"Survey [{SurveyID}] Item [{ID}] MoveOption id:{SurveyItemOptions[optionID].ID}");
|
|
|
|
+
|
|
|
|
+ int min = SurveyItemOptions.Select(o => o.Value.Position).Min();
|
|
|
|
+ int max = SurveyItemOptions.Select(o => o.Value.Position).Max();
|
|
|
|
+
|
|
|
|
+ Console.WriteLine($"min:{min}, max:{max}.");
|
|
|
|
+
|
|
|
|
+ int oldPosition, newPosition;
|
|
|
|
+ oldPosition = SurveyItemOptions[optionID].Position;
|
|
|
|
+
|
|
|
|
+ int targetPosition = (oldPosition + step < min) ? min : oldPosition + step;
|
|
|
|
+ targetPosition = (oldPosition + step > max) ? max : oldPosition + step;
|
|
|
|
+
|
|
|
|
+ Console.WriteLine($"oldPosition:{oldPosition}, step:{step}, target:{targetPosition}.");
|
|
|
|
+
|
|
|
|
+ int targetKey = SurveyItemOptions.FirstOrDefault(x => x.Value.Position == targetPosition).Key;
|
|
|
|
+ if (targetKey != 0)
|
|
|
|
+ {
|
|
|
|
+ newPosition = SurveyItemOptions[targetKey].Position;
|
|
|
|
+ Console.WriteLine($"newPosition:{newPosition}.");
|
|
|
|
+
|
|
|
|
+ SurveyItemOptions[optionID].Position = newPosition;
|
|
|
|
+ SurveyItemOptions[targetKey].Position = oldPosition;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|