public DetailedJobModelM()
 {
     Customer = new CustomerM();
     PhoneModel = new DetailedPhoneModelM();
     Job = new JobM();
     DeviceOrAccaccessories = new ObservableCollection<DeviceM>();
     RepareDetails = new RepareM();
     NewParts = new ObservableCollection<NewPartM>();
     DeveloperOrMechanist = new SystemUserM();
 }
Beispiel #2
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;
        }