예제 #1
0
 public Contact GetById(int id)
 {
     using (var db = new TradeEntities())
     {
         return(db.Contact.Find(id));
     }
 }
예제 #2
0
 public void Update(Contact contact)
 {
     using (var db = new TradeEntities())
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
     }
 }
예제 #3
0
 public void Create(Contact contact)
 {
     using (var db = new TradeEntities())
     {
         db.Contact.Add(contact);
         db.Entry(contact).State = EntityState.Added;
         db.SaveChanges();
     }
 }
예제 #4
0
 public bool IsDuplicate(Contact contact)
 {
     using (var db = new TradeEntities())
     {
         var item = db.Contact.Where(x => x.Name == contact.Name).FirstOrDefault();
         if (item != null && item.Id != contact.Id)
         {
             return(true);
         }
         return(false);
     }
 }
예제 #5
0
 public void Delete(int id)
 {
     using (var db = new TradeEntities())
     {
         var item = db.Contact.Find(id);
         if (item == null)
         {
             return;
         }
         db.Entry(item).State = EntityState.Deleted;
         db.SaveChanges();
     }
 }
예제 #6
0
        public IQueryable <Contact> GetAll()
        {
            var db = new TradeEntities();

            return(db.Contact.OrderBy(x => x.Name));
        }