示例#1
0
 public IEnumerable <ContactInformation> GetAll()
 {
     using (var dbContext = new ContactEntities())
     {
         return(dbContext.ContactInformations.AsEnumerable());
     }
 }
示例#2
0
 public ContactInformation Get(object id)
 {
     using (var dbContext = new ContactEntities())
     {
         return(dbContext.ContactInformations.FirstOrDefault(p => p.PersonId == id.ToString()));
     }
 }
示例#3
0
 public void Delete(ContactInformation entity)
 {
     using (var dbContext = new ContactEntities())
     {
         dbContext.ContactInformations.FirstOrDefault(p => p.PersonId == entity.PersonId.ToString());
         dbContext.ContactInformations.Remove(entity);
         dbContext.SaveChanges();
     }
 }
示例#4
0
        public ContactInformation Add(ContactInformation contactInfoItem)
        {
            if (contactInfoItem == null)
            {
                throw new ArgumentNullException("item");
            }

            using (var dbContext = new ContactEntities())
            {
                dbContext.ContactInformations.Add(contactInfoItem);
                dbContext.SaveChanges();
            }

            return(contactInfoItem);
        }
示例#5
0
        public bool Update(ContactInformation entity)
        {
            if (entity == null)
            {
                throw new ArgumentNullException("item");
            }
            var itemsUpdated = 0;

            using (var dbContext = new ContactEntities())
            {
                var dbEntity = dbContext.ContactInformations.Find(entity.PersonId);
                dbContext.Entry(dbEntity).CurrentValues.SetValues(entity);
                itemsUpdated = dbContext.SaveChanges();
            }

            return(itemsUpdated > 0);
        }