예제 #1
0
 public IList <Container> Lista()
 {
     using (var contexto = new TerminalContext())
     {
         return(contexto.Containers.Include("BL").ToList());
     }
 }
예제 #2
0
 public IList <BL> Lista()
 {
     using (var contexto = new TerminalContext())
     {
         return(contexto.BLs.ToList());
     }
 }
예제 #3
0
 public void Atualiza(BL bl)
 {
     using (var contexto = new TerminalContext())
     {
         contexto.Entry(bl).State = System.Data.Entity.EntityState.Modified;
         contexto.SaveChanges();
     }
 }
예제 #4
0
 public IList <Container> BuscaPorBL(int Id)
 {
     using (var contexto = new TerminalContext())
     {
         return(contexto.Containers.Include("BL")
                .Where(c => c.BLId == Id).ToList());
     }
 }
예제 #5
0
 public void Adiciona(Container container)
 {
     using (var context = new TerminalContext())
     {
         context.Containers.Add(container);
         context.SaveChanges();
     }
 }
예제 #6
0
 public BL BuscaPorId(int id)
 {
     using (var contexto = new TerminalContext())
     {
         return(contexto.BLs
                .Where(c => c.Id == id)
                .FirstOrDefault());
     }
 }
예제 #7
0
 public void Apagar(int id)
 {
     using (var contexto = new TerminalContext())
     {
         var container = contexto.Containers.Include("BL").Single(c => c.Id == id);
         contexto.Containers.Remove(container);
         contexto.SaveChanges();
     }
 }
예제 #8
0
 public Container BuscaPorId(int id)
 {
     using (var contexto = new TerminalContext())
     {
         return(contexto.Containers.Include("BL")
                .Where(c => c.Id == id)
                .FirstOrDefault());
     }
 }
예제 #9
0
 public void Apagar(int id)
 {
     using (var contexto = new TerminalContext())
     {
         var bl         = contexto.BLs.Single(c => c.Id == id);
         var containers = contexto.Containers
                          .Where(c => c.BLId == id);
         contexto.Containers.RemoveRange(containers);
         contexto.BLs.Remove(bl);
         contexto.SaveChanges();
     }
 }
예제 #10
0
 public void Adiciona(BL bl)
 {
     using (var context = new TerminalContext())
     {
         if (BuscaPorId(bl.Id) == null)
         {
             context.BLs.Add(bl);
             context.SaveChanges();
         }
         else
         {
             Atualiza(bl);
         }
     }
 }