public static void Save(DetallePedido detalle)
        {
            using (var db = new PizzeriaDbContext())
            {
                try
                {
                    if (detalle.id != 0)
                    {
                        db.Entry(detalle).State = EntityState.Modified;
                    }
                    else
                    {
                        db.Entry(detalle.pizza).State  = EntityState.Unchanged;
                        db.Entry(detalle.pedido).State = EntityState.Unchanged;

                        db.Detalle.Add(detalle);
                    }
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Error al guardar. " + ex.Message);
                }
            }
        }
Ejemplo n.º 2
0
        public static void Save(Pizza p)
        {
            using (var db = new PizzeriaDbContext())
            {
                try
                {
                    if (p.id != 0)
                    {
                        db.Entry(p).State = EntityState.Modified;
                    }
                    else
                    {
                        foreach (var i in p.ingredientes)
                        {
                            db.Entry(i).State = EntityState.Unchanged;
                        }

                        db.Pizza.Add(p);
                    }
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new ApplicationException("Error al guardar. " + ex.Message);
                }
            }
        }
Ejemplo n.º 3
0
 public static Pizza Get(int Id)
 {
     using (var db = new PizzeriaDbContext())
     {
         Pizza pizza = db.Pizza.Where(p => p.id == Id).FirstOrDefault();
         return(pizza);
     }
 }
Ejemplo n.º 4
0
 public ServicioVentas(PizzeriaDbContext context, IRepositorioVentas repositorio,
                       IRepositorioItemVentas repositorioItems, IUnitOfWork unitOfWork)
 {
     _context          = context;
     _repositorio      = repositorio;
     _repositorioItems = repositorioItems;
     _unitOfWork       = unitOfWork;
     _mapper           = Mapeador.Mapeador.CrearMapper();
 }
        public static List <DetallePedido> GetAllJoinPedido()
        {
            using (var db = new PizzeriaDbContext())
            {
                List <DetallePedido> det = db.Detalle.Include(d => d.pedido).ToList();

                return(det);
            }
        }
        public static List <DetallePedido> GetAll()
        {
            using (var db = new PizzeriaDbContext())
            {
                List <DetallePedido> det = db.Detalle.ToList();

                return(det);
            }
        }
 public static DetallePedido Get(int Id)
 {
     using (var db = new PizzeriaDbContext())
     {
         DetallePedido detalle = db.Detalle.Where(d => d.id == Id)
                                 .Include(p => p.pedido).FirstOrDefault();
         return(detalle);
     }
 }
Ejemplo n.º 8
0
        public static List <Pizza> GetAll()
        {
            using (var db = new PizzeriaDbContext())
            {
                List <Pizza> pizzas = db.Pizza.ToList();

                return(pizzas);
            }
        }
        public static List <Ingrediente> GetAll()
        {
            using (var db = new PizzeriaDbContext())
            {
                List <Ingrediente> ing = db.Ingrediente.ToList();

                return(ing);
            }
        }
 public static void Save(Ingrediente i)
 {
     using (var db = new PizzeriaDbContext())
     {
         try
         {
             if (i.id != 0)
             {
                 db.Entry(i).State = EntityState.Modified;
             }
             else
             {
                 db.Ingrediente.Add(i);
             }
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new ApplicationException("Error al guardar. " + ex.Message);
         }
     }
 }
Ejemplo n.º 11
0
 public static void Save(Factura factura)
 {
     using (var db = new PizzeriaDbContext())
     {
         try
         {
             if (factura.id != 0)
             {
                 db.Entry(factura).State = EntityState.Modified;
             }
             else
             {
                 db.Entry(factura.pedido).State = EntityState.Unchanged;
                 db.Factura.Add(factura);
             }
             db.SaveChanges();
         }
         catch (Exception ex)
         {
             throw new ApplicationException("Error al guardar. " + ex.Message);
         }
     }
 }
Ejemplo n.º 12
0
 public ServicioVentas(PizzeriaDbContext context)
 {
     _context = context;
     _mapper  = Mapeador.Mapeador.CrearMapper();
 }
Ejemplo n.º 13
0
 public RepositorioProductos(PizzeriaDbContext context)
 {
     _context = context;
     _mapper  = Mapeador.Mapeador.CrearMapper();
 }
 public RepositorioItemVentas(PizzeriaDbContext context)
 {
     _context = context;
     _mapper  = Mapeador.Mapeador.CrearMapper();
 }
Ejemplo n.º 15
0
 public UnitOfWork(PizzeriaDbContext context)
 {
     _context = context;
 }