public static Boolean EliminarProductoDeBodega(int idProducto, int idBodega) { using (var context = new WebBotilleriaEntities()) { if (context.DetalleBodegaLocals.Where(c => c.id_bodega_fk == idBodega).Where(c => c.id_bebida_fk == idProducto).FirstOrDefault().cantidad == 0) { context.DeleteObject(context.DetalleBodegaLocals.Where(c => c.id_bodega_fk == idBodega).Where(c => c.id_bebida_fk == idProducto).FirstOrDefault()); context.SaveChanges(); return true; } else return false; } }
public static Boolean EliminarBodega(int idBodegaEliminar) { using (var context = new WebBotilleriaEntities()) { foreach (Bebida item in BuscarProductosEnBodega(idBodegaEliminar)) { if (!EliminarProductoDeBodega(item.ID, idBodegaEliminar)) return false; } context.DeleteObject(context.Bodegas.FirstOrDefault().id_bodega == idBodegaEliminar); context.SaveChanges(); } return true; }