public List <Phone> GetPhone() { using (var context = new PersondbContext()) { List <Phone> phones = context.Phone.ToListAsync().Result; return(phones); } }
public Phone GetPhoneById(int id) { using (var context = new PersondbContext()) { var phone = context.Phone.FirstOrDefault(p => p.Id == id); return(phone); } }
public void Create(Phone phone) { using (var context = new PersondbContext()) { context.Add(phone); context.SaveChanges(); } }
public Phone GetPhoneById(int id) { using (var context = new PersondbContext()) { var phone = context.Phone.Find(id); return(phone); } }
public void Create(Phone phone) { using (var context = new PersondbContext()) { try { context.Add(phone); context.SaveChanges(); } catch (SqlException ex) { Console.WriteLine(ex.Message + ex.LineNumber); } } }
public PeopleController(PersondbContext context) { _context = context; }
public PersonRepository(PersondbContext context) { _context = context; }
//Default constructor public PersonRepository() { _context = new PersondbContext(); }