Skip to content

Instantly share code, notes, and snippets.

@TimGeyssens
Created January 30, 2014 12:37
Show Gist options
  • Save TimGeyssens/8707542 to your computer and use it in GitHub Desktop.
Save TimGeyssens/8707542 to your computer and use it in GitHub Desktop.
int score = 0;
Dictionary<string, int> scores = new Dictionary<string, int>();
foreach (string mapping in Scoremappings.Split(';'))
{
if (!string.IsNullOrEmpty(mapping) && mapping.Split(',').Length > 0)
{
int weight = 0;
scores.Add(mapping.Split(',')[0], int.TryParse(mapping.Split(',')[1], out weight) ? weight : 0);
}
}
PreValueStorage pvs = new PreValueStorage();
foreach (RecordField rf in record.RecordFields.Values)
{
if (rf.Field.FieldType.GetType() == typeof (Umbraco.Forms.Core.Providers.FieldTypes.RadioButtonList))
{
if (rf.Values.Count > 0)
{
var pvkey = pvs.GetAllPreValues(rf.Field).First(p => p.Value == rf.Values[0].ToString()).Id;
if (scores.ContainsKey(pvkey.ToString()))
score += scores[pvkey.ToString()];
}
}
}
pvs.Dispose();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment