Skip to content

Instantly share code, notes, and snippets.

@Nicholas-Westby
Created May 12, 2018 22:54
Show Gist options
  • Save Nicholas-Westby/b92a1e7264857813e425482f8ca1268c to your computer and use it in GitHub Desktop.
Save Nicholas-Westby/b92a1e7264857813e425482f8ca1268c to your computer and use it in GitHub Desktop.
Merges field data into the data submitted for a form.
/// <summary>
/// Merges the specified field value into the collection of field submissions.
/// </summary>
/// <param name="data">
/// The collection to merge the field value into.
/// </param>
/// <param name="field">
/// The field to merge.
/// </param>
/// <param name="fieldValue">
/// The value to merge in for the field.
/// </param>
private static void MergeFieldData(List<FieldSubmission> data, IFormField field, string fieldValue)
{
var fieldData = data.FirstOrDefault(x => x.FieldId == field.Id);
if (fieldData == null)
{
fieldData = new FieldSubmission()
{
FieldId = field.Id
};
data.Add(fieldData);
}
fieldData.FieldValues = new List<string>() { fieldValue };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment