public void ModifyRecord(int id, string name, string familyName, string phoneNumber) { PB_RECORDS rec = TakeRecord(id); rec.PBR_NAME = name; rec.PBR_PHONE_NUMBER = phoneNumber; rec.PBR_FAMILY_NAME = familyName; ent.SaveChanges(); }
public PB_RECORDS TakeRecord(int id, pbEntities ent) { PB_RECORDS rec = ent.PB_RECORDS.Where(o => o.PBR_ID == id).FirstOrDefault(); if (rec == null) { throw new Exception(string.Format("record with id:{0} does not persist", id)); } return(rec); }
public int AddRecord(string name, string familyName, string phoneNumber) { PB_RECORDS rec = ent.PB_RECORDS.Add(new PB_RECORDS { PBR_FAMILY_NAME = familyName, PBR_NAME = name, PBR_PHONE_NUMBER = phoneNumber }); ent.SaveChanges(); return(rec.PBR_ID); }