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); } } }
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); } } }
public static Pizza Get(int Id) { using (var db = new PizzeriaDbContext()) { Pizza pizza = db.Pizza.Where(p => p.id == Id).FirstOrDefault(); return(pizza); } }
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); } }
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); } } }
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); } } }
public ServicioVentas(PizzeriaDbContext context) { _context = context; _mapper = Mapeador.Mapeador.CrearMapper(); }
public RepositorioProductos(PizzeriaDbContext context) { _context = context; _mapper = Mapeador.Mapeador.CrearMapper(); }
public RepositorioItemVentas(PizzeriaDbContext context) { _context = context; _mapper = Mapeador.Mapeador.CrearMapper(); }
public UnitOfWork(PizzeriaDbContext context) { _context = context; }