private List <TaxoVM> ConvertToVM(List <dynamic> obj)
        {
            List <TaxoVM> listatvm = new List <TaxoVM>();

            foreach (dynamic el in obj)
            {
                TaxoVM newel = new TaxoVM();
                newel.Id = Convert.ToInt32(el);
                listatvm.Add(newel);
            }
            return(listatvm);
        }
Exemple #2
0
        //private TaxoVM FindTaxoVM(List<TaxoVM> elements, Int32 idToFind) {
        //    if (elements != null) {
        //        foreach (TaxoVM myterm in elements) {
        //            if (myterm.Id == idToFind)
        //                return myterm;
        //            else
        //                return FindTaxoVM(myterm.child, idToFind);
        //        }
        //        return null;
        //    }
        //    else
        //        return null;
        //}
        private List <TaxoVM> ConvertToVM(List <dynamic> obj)
        {
            List <TaxoVM> listatvm = new List <TaxoVM>();

            foreach (dynamic el in obj)
            {
                TaxoVM newel = new TaxoVM();
                try {
                    newel.flag = el.flag;
                }
                catch {
                }
                newel.Id = Convert.ToInt32(el.Id);
                try {
                    newel.testo = el.testo ?? "";
                }
                catch {
                }
                try {
                    newel.valore = (string)el.valore ?? "";
                }
                catch {
                }
                //  newel.child = ConvertToVM((List < dynamic >)  el.child);
                listatvm.Add(newel);
                try {
                    if (el.child != null)
                    {
                        foreach (TaxoVM tv in ConvertToVM((List <dynamic>)el.child))
                        {
                            listatvm.Add(tv);
                        }
                    }
                }
                catch {
                }
            }
            return(listatvm);
        }