@@ -0,0 +1,2958 @@
+package com.serviq.serviq;%0A%0Aimport android.content.ContentValues;%0Aimport android.content.Context;%0Aimport android.database.Cursor;%0Aimport android.database.sqlite.SQLiteDatabase;%0Aimport android.database.sqlite.SQLiteOpenHelper;%0A%0Aimport java.util.ArrayList;%0Aimport java.util.List;%0A%0A/**%0A * Created by gildardo on 10/12/16.%0A */%0A%0Apublic class CarritoItemDataSource %7B%0A%0A    private SQLiteOpenHelper dbhelper;%0A    private SQLiteDatabase database;%0A    private Context mContext;%0A    private static final String%5B%5D allColumns = %7B%0A            ServiqDBOpenHelper.ITEM_COLUMN_ID,%0A            ServiqDBOpenHelper.ITEM_COLUMN_CANT,%0A            ServiqDBOpenHelper.ITEM_COLUMN_DESC,%0A            ServiqDBOpenHelper.ITEM_COMIDA_ID%0A    %7D;%0A%0A    public CarritoItemDataSource(Context context)%0A    %7B%0A        dbhelper = new ServiqDBOpenHelper(context);%0A        mContext = context;%0A    %7D%0A%0A    public void open()%0A    %7B%0A        database = dbhelper.getWritableDatabase();%0A    %7D%0A%0A    public void close()%0A    %7B%0A        dbhelper.close();%0A    %7D%0A%0A    public CarritoItem create(CarritoItem carritoItem)%0A    %7B%0A        ContentValues values = new ContentValues();%0A        values.put(ServiqDBOpenHelper.ITEM_COLUMN_ID, carritoItem.getId());%0A        values.put(ServiqDBOpenHelper.ITEM_COLUMN_CANT, carritoItem.getCantidad());%0A        values.put(ServiqDBOpenHelper.ITEM_COLUMN_DESC, carritoItem.getDescripcion());%0A        values.put(ServiqDBOpenHelper.ITEM_COMIDA_ID, carritoItem.getComida().getId());%0A        long insertId = database.insert(ServiqDBOpenHelper.TABLE_CARRITO_ITEM, null, values);%0A        carritoItem.setId(insertId);%0A        return carritoItem;%0A    %7D%0A%0A    public List%3CCarritoItem%3E findAll()%0A    %7B%0A        List%3CCarritoItem%3E items = new ArrayList%3C%3E();%0A        Cursor cursor = database.query(ServiqDBOpenHelper.TABLE_CARRITO_ITEM, allColumns,%0A                null, null, null, null, null);%0A%0A        if (cursor.getCount() != 0) %7B%0A            while (cursor.moveToNext()) %7B%0A                CarritoItem item = new CarritoItem();%0A                item.setId(cursor.getLong(cursor.getColumnIndex(%0A                        ServiqDBOpenHelper.ITEM_COLUMN_ID)%0A                ));%0A%0A                item.setCantidad(cursor.getInt(cursor.getColumnIndex(%0A                        ServiqDBOpenHelper.ITEM_COLUMN_CANT)%0A                ));%0A%0A                item.setDescripcion(cursor.getString(cursor.getColumnIndex(%0A                        ServiqDBOpenHelper.ITEM_COLUMN_DESC)%0A                ));%0A%0A                //Agrega una nueva comida en el Carrito Item%0A                long comidaId = cursor.getLong(cursor.getColumnIndex(%0A                        ServiqDBOpenHelper.ITEM_COMIDA_ID)%0A                );%0A%0A                ComidaDataSource dao = new ComidaDataSource(mContext);%0A                Comida comida = dao.getComidaById(comidaId);%0A                if (comida != null)%0A                    item.setComida(comida);%0A%0A                items.add(item);%0A            %7D%0A        %7D%0A        return items;%0A    %7D%0A%7D%0A

Add CarritoItem datasource