package com.toscana.controller.sales;

import com.toscana.model.dao.implementations.DataSaleDAOImplementation;
import com.toscana.model.dao.interfaces.DataSaleDAO;
import com.toscana.model.products.Product;
import com.toscana.model.reports.sources.DataSale;

public class SaleController {

    /*
     * Class methods
     */
    
    
    public SaleController(){
        this.sale = new DataSale();
        this.saleDAO = new DataSaleDAOImplementation();
    }

    
    
    public void addProductToCurrentSale(Product productToAdd){
        sale.addAProductToProductsInSale(productToAdd);
    }
    
    public void increaseSaleTotalAmount(Product product){
        double productPrice = product.getPrice();
        double oldSaleAmount, newSaleAmount;
        oldSaleAmount=sale.getTotal();
        newSaleAmount= oldSaleAmount + productPrice;
        sale.setTotal(newSaleAmount);
    }
    
    public void saveCurrentSale(){
        try {
            saleDAO.add(sale);
        } catch (Exception e) {
        }
    }
    
    /*
     * Getters and Setters
     */
    public DataSale getSale() {
        return sale;
    }
    
    public DataSale getNewSale(){
        DataSale newSale = new DataSale();
        newSale.setTotal(INITAL_TOTAL_AMOUNT);
        
        return newSale;
    }

    public void setSale(DataSale sale) {
        this.sale = sale;
    }

     /*
     * Inner methods
     */
    
     /*
     * Attributes
     */
    private DataSale sale;
    private DataSaleDAO saleDAO;
    private static double INITAL_TOTAL_AMOUNT = 0.0;
}

@@ -32,16 +32,68 @@
 sales;%0A%0A
+import com.toscana.dao.managers.DataSaleDAOManager;%0A
 import c
@@ -156,16 +156,16 @@
 tation;%0A
-
 import c
@@ -466,16 +466,23 @@
 .saleDAO
+Manager
  = new D
@@ -491,30 +491,23 @@
 aSaleDAO
-Implementation
+Manager
 ();%0A    
@@ -1011,16 +1011,23 @@
  saleDAO
+Manager
 .add(sal
@@ -1553,24 +1553,31 @@
 aSaleDAO
+Manager
  saleDAO
 ;%0A    pr
@@ -1568,16 +1568,23 @@
  saleDAO
+Manager
 ;%0A    pr

Update SaleController