示例#1
0
 public People GetPerson(int id)
 {
     using (TestowaContext db = new TestowaContext())
     {
         return(db.People.Single(g => g.Id == id));
     }
 }
示例#2
0
 public List <People> GetPeople()
 {
     using (TestowaContext db = new TestowaContext())
     {
         return(db.People.ToList());
     }
 }
示例#3
0
 public void DeletePerson(int id)
 {
     using (TestowaContext db = new TestowaContext())
     {
         db.People.Remove(db.People.Single(g => g.Id == id));
         db.SaveChanges();
     }
 }
示例#4
0
 public void AddPerson(string firstName, string lastName, int phonNumber)
 {
     using (TestowaContext db = new TestowaContext())
     {
         db.People.Add(new People()
         {
             FirstName = firstName, LastName = lastName, PhoneNumber = phonNumber
         });
         db.SaveChanges();
     }
 }
示例#5
0
 public void ModifyPerson(int id, string firstName, string lastName, int phonNumber)
 {
     using (TestowaContext db = new TestowaContext())
     {
         People person = new People()
         {
             Id = id, FirstName = firstName, LastName = lastName, PhoneNumber = phonNumber
         };
         db.Entry(person).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
         db.SaveChanges();
     }
 }