public List <FormResponseProperties> GetChildResponseList(string parentResponseId, string childFormName, bool addIfNoList = false, bool includeDeletedRecords = false)
        {
            Dictionary <string /*ChildFormId*/, List <FormResponseProperties> > childResponsesByChildFormId = null;

            childResponsesByChildFormId = (ChildResponses.TryGetValue(parentResponseId, out childResponsesByChildFormId)) ? childResponsesByChildFormId : null;
            if (childResponsesByChildFormId == null && addIfNoList)
            {
                ChildResponses.Add(parentResponseId, childResponsesByChildFormId = new Dictionary <string /*ChildFormId*/, List <FormResponseProperties> >());
            }

            List <FormResponseProperties> childResponseList = null;

            if (childResponsesByChildFormId != null)
            {
                childResponseList = (childResponsesByChildFormId.TryGetValue(childFormName, out childResponseList)) ? childResponseList : null;
                if (childResponseList == null && addIfNoList)
                {
                    childResponsesByChildFormId.Add(childFormName, childResponseList = new List <FormResponseProperties>());
                }
            }
            if (childResponseList != null && childResponseList.Count > 0 && includeDeletedRecords == false)
            {
                childResponseList = childResponseList.Where(r => r.RecStatus != RecordStatus.Deleted).ToList();
            }
            return(childResponseList);
        }
        public void CascadeThroughChildren(FormResponseProperties formResponseProperties, Action <FormResponseProperties> action)
        {
            Dictionary <string /*ChildFormName*/, List <FormResponseProperties> > childFormResponses = null;

            if (ChildResponses.TryGetValue(formResponseProperties.ResponseId, out childFormResponses))
            {
                // interate over list child forms
                foreach (var childFormResponseList in childFormResponses.Values.ToArray())
                {
                    // iterate over list of child responses
                    foreach (var childFormResponseProperties in childFormResponseList.ToArray())
                    {
                        action(childFormResponseProperties);
                        AddOrReplaceChildResponse(childFormResponseProperties);
                        CascadeThroughChildren(childFormResponseProperties, action);
                    }
                }
            }
        }