private CheckListItemViewModel GetValuesFromForm( FormCollection formcollection, List<string> keys, string prefix )
        {
            var chk = new CheckListItemViewModel();

            var keyPrefix = prefix + ".";
            foreach(var str in keys)
            {
                var propName = str.Replace(keyPrefix,"");
                var pinfo = chk.GetType().GetProperty(propName);
                if(pinfo != null) //property found
                {
                    var keyVal = formcollection.GetValue(str);
                    pinfo.SetValue(chk, keyVal.ConvertTo(pinfo.PropertyType));
                }
                else
                {
                    if(chk.ChecklistAnswerData == null)
                    {
                        chk.ChecklistAnswerData = new List<CheckListUserDataViewModel>();
                    }
                    chk.ChecklistAnswerData.Add(new CheckListUserDataViewModel {
                        Key = propName,
                        Answer = formcollection.GetValue(str).ToString() });
                }

            }
            chk.Key = prefix;
            return chk;
        }
 public List<CheckListItemViewModel> UpdateFromDataModel(List<CheckListTemplate> templateDataCollection)
 {
     _listItems.Clear();
     _dictionary.Clear();
     templateDataCollection.ForEach(a => {
         var vm = new CheckListItemViewModel
                {
                    Key = a.Key,
                    ChecklistItem = a.ChecklistItem,
                    Enabled = a.Enabled,
                    PostVerificationRequired = a.PostVerificationRequired
                };
         _dictionary.Add( a.Key, vm);
         _listItems.Add(vm);
     });
     return _listItems; //render to view
 }
 public List<CheckListItemViewModel> UpdateFromDataModel(List<CheckListTestPlan> testplanDataCollection)
 {
     _listItems.Clear();
     _dictionary.Clear();
     testplanDataCollection.ForEach(a => {
         var tpData = new CheckListItemViewModel
         {
             Key = a.Key,
             ChecklistItem = a.ChecklistItem,
             Verified = a.Verified,
             VerifiedBy = a.PostVerifiedBy,
             VerifiedDate = a.VerifiedDate,
             PostVerified = a.PostVerified,
             PostVerifiedBy = a.PostVerifiedBy,
             PostVerfiedDate = a.PostVerfiedDate,
             PostVerificationRequired = a.PostVerificationRequired
         };
         if( a.CheckListUserData != null && a.CheckListUserData.Count > 0 )
         {
             tpData.ChecklistAnswerData = new List<CheckListUserDataViewModel>();
             a.CheckListUserData.ToList().ForEach(v => { tpData.ChecklistAnswerData.Add(new CheckListUserDataViewModel { Key = v.Key, Answer = v.Answer }); });
         }
         _listItems.Add(tpData);
         _dictionary.Add(a.Key, tpData);
     });
     return _listItems; //render to view
 }
        public List<CheckListItemViewModel> UpdateFromDataModel(List<ChecklistData> defaultDataCollection)
        {
            //populate both;
            _listItems.Clear();
            _dictionary.Clear();
            defaultDataCollection.ForEach(a => {

                var vm = new CheckListItemViewModel
                {
                    Key = a.Key,
                    ChecklistItem = a.ChecklistItem,
                    Enabled = true
                };

                _dictionary.Add(a.Key, vm );
                _listItems.Add(vm);
            });
            return _listItems; //render to view
        }