-
-
Save Nicholas-Westby/b92a1e7264857813e425482f8ca1268c to your computer and use it in GitHub Desktop.
Merges field data into the data submitted for a form.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <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