예제 #1
0
 public static bool Save(CEP obj)
 {
     obj.dataCriacao = DateTime.Now;
     obj.dataEdicao  = DateTime.Now;
     try
     {
         if (obj.ID == 0)
         {
             using (var db = new WebPixEntregaContext())
             {
                 db.CEP.Add(obj);
                 db.SaveChanges();
             }
             return(true);
         }
         else
         {
             using (var db = new WebPixEntregaContext())
             {
                 db.CEP.Update(obj);
                 db.SaveChanges();
                 return(true);
             }
         }
     }
     catch (Exception e)
     {
         return(false);
     }
 }
예제 #2
0
 public static List <CEP> GetAll()
 {
     try
     {
         using (var db = new WebPixEntregaContext())
         {
             return(db.CEP.ToList());
         }
     }
     catch (Exception e)
     {
         ////
         return(new List <CEP>());
     }
 }
예제 #3
0
 public static List <Transportadora> GetAll()
 {
     try
     {
         using (var db = new WebPixEntregaContext())
         {
             return(db.Transportadora.ToList());
         }
     }
     catch (Exception e)
     {
         ////
         return(new List <Transportadora>());
     }
 }
예제 #4
0
 public static bool Remove(CEP obj)
 {
     try
     {
         using (var db = new WebPixEntregaContext())
         {
             db.CEP.Remove(obj);
             db.SaveChanges();
             return(true);
         }
     }
     catch (Exception e)
     {
         ////
         return(false);
     }
 }