Ejemplo n.º 1
0
        internal ObservableCollection<DetailedPhoneModelM> GetAllPhoneModels()
        {
            ObservableCollection<DetailedPhoneModelM> phoneModels = new ObservableCollection<DetailedPhoneModelM>();
            using (PhoneShopdbEntities ctx = new PhoneShopdbEntities())
            {

                var brands = ctx.PhoneBrands.ToList();

                foreach (var item in brands)
                {
                    DetailedPhoneModelM phoneM = new DetailedPhoneModelM();
                    phoneM.Id = (int)item.Id;
                    phoneM.BrandName = (string)item.BrandName;
                    var models = ctx.PhoneModels.Where(x => x.Brand_Id == item.Id).ToList();
                    foreach (var m in models)
                    {
                        PhoneModelM pm = new PhoneModelM();
                        pm.Id = m.Id;
                        pm.BrandId = (int)m.Brand_Id;
                        pm.ModelNumber = m.ModelNumber;
                        pm.ImageURI = m.ImageURI;
                        phoneM.PhoneModels.Add(pm);
                    }
                    phoneModels.Add(phoneM);
                }
            }
            return phoneModels;
        }
Ejemplo n.º 2
0
 public DetailedPhoneModelM()
 {
     PhoneModels = new ObservableCollection<PhoneModelM>();
     SelectedPhoneModel = new PhoneModelM();
 }