public tblProvider GetProviderById(int id)
 {
     using (var db = new ProviderDAL())
     {
         return(db.tblProviders.FirstOrDefault(p => p.providerID == id));
     }
 }
 public tblProvider GetProviderByName(string name)
 {
     using (var db = new ProviderDAL())
     {
         return(db.tblProviders
                .Where(p => p.name == name)
                .FirstOrDefault());
     }
 }
 public List <tblProvider> GetBlockedProviders()
 {
     using (var db = new ProviderDAL())
     {
         return(db.tblProviders
                .Where(x => x.blocked == true)
                .ToList());
     }
 }
 public int AddProvider(tblProvider provider)
 {
     if (provider != null)
     {
         using (var db = new ProviderDAL())
         {
             db.tblProviders.Add(provider);
             db.SaveChanges();
             return(provider.providerID);
         }
     }
     return(0);
 }
 public int BlockById(int id)
 {
     using (var db = new ProviderDAL())
     {
         var result = db.tblProviders.SingleOrDefault(p => p.providerID == id);
         if (result != null)
         {
             result.blocked = true;
             db.SaveChanges();
             return(result.providerID);
         }
         return(0);
     }
 }
 public int DeleteProviderById(int id)
 {
     using (var db = new ProviderDAL())
     {
         tblProvider provider = GetProviderById(id);
         if (provider != null)
         {
             db.Entry(provider).State = EntityState.Deleted;
             db.SaveChanges();
             return(1);
         }
         return(0);
     }
 }