Example #1
0
 public List <Phone> ReadPhones()
 {
     using (var context = new PhonepersondbContext())
     {
         List <Phone> phones = context.Phone.ToListAsync().Result;
         return(phones);
     }
 }
Example #2
0
        public Phone PhoneAndId(int id)
        {
            using (var context = new PhonepersondbContext())
            {
                var phones = context.Phone.FirstOrDefault(p => p.Id == id);

                return(phones);
            }
        }
Example #3
0
 public void Create(Phone phone)
 {
     using (var context = new PhonepersondbContext())
     {
         try
         {
             context.Add(phone);
             context.SaveChanges();
         }
         catch (Exception)
         {
             throw;
         }
     }
 }