Example #1
0
 public bool AddContact(Contact contact)
 {
     using (var context = new NotebookDBContext())
     {
         context.Contact.Add(contact);
         var result = context.SaveChanges();
         return(result > 0);
     }
 }
Example #2
0
        public List <Contact> GetAllContacts(bool includeDeleted)
        {
            using (var context = new NotebookDBContext())
            {
                var query = context.Contact.AsQueryable();
                if (!includeDeleted)
                {
                    query = query.Where(x => x.IsDeleted == false);
                }

                return(query.ToList());
            }
        }
Example #3
0
        public bool DeleteContactById(int contactId)
        {
            using (var context = new NotebookDBContext())
            {
                var contactDelete = context.Contact.FirstOrDefault(x => x.Id == contactId);
                if (contactDelete == null)
                {
                    return(false);
                }

                contactDelete.IsDeleted = true;
                return(context.SaveChanges() > 0);
            }
        }