package javaphone;

import java.awt.BorderLayout;
import java.util.ArrayList;
import java.util.HashMap;

/**
 * This controller class is responsible for communication between
 * the GUI and the model classes.
 * 
 * @author iGroup
 */
public class LpPhoneMain {

    private int activeUser;
    private final ServiceList serviceList;
    private final UserList userList;
    private final CustomerList customerList;

    /**
     * Constructor for class LpPhoneMain.
     */
    public LpPhoneMain() {
        serviceList = new ServiceList();
        userList = new UserList();
        customerList = new CustomerList();
    }

    public void runProgram() {
        //login();
    }

    private boolean setActiveUser(int userId) {
        activeUser = userId;
        return true;
    }

    public int getActiveUser() {
        return activeUser;
    }

    private boolean login(int userId, String password) {
        if (sendUserPassword(userId).equals(password)) {
            setActiveUser(userId);
            return true;
        } else {
            return false;
        }
    }

    public String getNextContract() {
        return customerList.getNextContract();
    }

    public boolean addCustomer(HashMap customerData) {
        return customerList.add(customerData);
    }

    public ArrayList getCustomerList(User user, Service service) {
        return customerList.filter(user, service);
    }

    public ArrayList getCustomerData(Customer customer) {
        return customerList.getCustomerData(customer);
    }

    public boolean changeCustomerData(Customer customer, HashMap customerData) {
        return customerList.changeCustomerData(customer, customerData);
    }

    public int getCustomerNoByService(Service service) {
        return customerList.getCustomerNoByService(service);
    }

    public ArrayList getUserList() {
        return userList;
    }

    public ArrayList getUserData(User user) {
        return userList.getUserData(user);
    }

    public boolean changeUserData(User user, HashMap userData) {
        return userList.changeUserData(user, userData);
    }

    public String sendUserPassword(int userId) {
        return userList.sendUserPassword(userId);
    }

    public ArrayList getServiceList() {
        return serviceList;
    }

    public double getServicePrice(Service service) {
        return serviceList.getServicePrice(service);
    }

    public boolean setServicePrice(Service service, double price) {
        return serviceList.setServicePrice(service, price);
    }
}

@@ -17,38 +17,8 @@
 e;%0A%0A
-import java.awt.BorderLayout;%0A
 impo
@@ -137,19 +137,16 @@
  between
-%0A *
  the GUI
@@ -149,16 +149,19 @@
  GUI and
+%0A *
  the mod
@@ -174,17 +174,16 @@
 sses.%0A *
- 
 %0A * @aut
@@ -888,21 +888,42 @@
     if (
-sendU
+getUserById(userId).get(%22u
 serPassw
@@ -925,23 +925,17 @@
 Password
-(userId
+%22
 ).equals
@@ -1310,34 +1310,112 @@
 ist(
-User user, Service
+) %7B%0A        return customerList;%0A    %7D%0A    %0A    public ArrayList getCustomerList(int userId, int
  service
 ) %7B%0A
@@ -1402,32 +1402,34 @@
 rId, int service
+Id
 ) %7B%0A        retu
@@ -1455,16 +1455,18 @@
 ter(user
+Id
 , servic
@@ -1462,24 +1462,26 @@
 rId, service
+Id
 );%0A    %7D%0A%0A  
@@ -1469,32 +1469,36 @@
 rviceId);%0A    %7D%0A
+    
 %0A    public Arra
@@ -1489,33 +1489,31 @@
 %0A    public 
-ArrayList
+HashMap
  getCustomer
@@ -1508,37 +1508,32 @@
  getCustomer
-Data(Customer
+ById(int
  customer) %7B
@@ -1529,16 +1529,18 @@
 customer
+Id
 ) %7B%0A    
@@ -1566,36 +1566,36 @@
 List.getCustomer
-Data
+ById
 (customer);%0A    
@@ -1587,16 +1587,18 @@
 customer
+Id
 );%0A    %7D
@@ -1591,32 +1591,34 @@
 omerId);%0A    %7D%0A%0A
+/*
     public boole
@@ -1752,32 +1752,34 @@
 merData);%0A    %7D%0A
+*/
 %0A    public int 
@@ -1797,39 +1797,35 @@
 NoByService(
-Service
+int
  service
 ) %7B%0A        
@@ -1804,32 +1804,34 @@
 vice(int service
+Id
 ) %7B%0A        retu
@@ -1868,32 +1868,34 @@
 yService(service
+Id
 );%0A    %7D%0A%0A    pu
@@ -1972,39 +1972,38 @@
 lic 
-ArrayList getUserData(User
+HashMap getUserById(int
  user
+Id
 ) %7B%0A
@@ -2042,16 +2042,18 @@
 ata(user
+Id
 );%0A    %7D
@@ -2045,33 +2045,40 @@
 (userId);%0A    %7D%0A
-%0A
+    /*%0A 
     public boole
@@ -2123,35 +2123,32 @@
 serData) %7B%0A     
-   
 return userList.
@@ -2171,37 +2171,46 @@
 ser, userData);%0A
+ 
     %7D
+%0A     */
 %0A%0A    public Str
@@ -2210,42 +2210,33 @@
 lic 
-String sendUserPassword(int userId
+ArrayList getServiceList(
 ) %7B%0A
@@ -2254,49 +2254,27 @@
 urn 
-u
 ser
+vice
 List
-.sendUserPassword(userId)
 ;%0A    %7D%0A
 %0A   
@@ -2261,32 +2261,36 @@
 viceList;%0A    %7D%0A
+    
 %0A    public Arra
@@ -2297,37 +2297,50 @@
 yList getService
-List(
+ById(int serviceId
 ) %7B%0A        retu
@@ -2345,32 +2345,58 @@
 turn serviceList
+.getServiceById(serviceId)
 ;%0A    %7D%0A%0A    pub
@@ -2422,31 +2422,27 @@
 cePrice(
-Service
+int
  service
 ) %7B%0A    
@@ -2433,16 +2433,18 @@
  service
+Id
 ) %7B%0A    
@@ -2489,16 +2489,18 @@
 (service
+Id
 );%0A    %7D
@@ -2540,23 +2540,19 @@
 ice(
-Service
+int
  service
 , do
@@ -2547,16 +2547,18 @@
  service
+Id
 , double
@@ -2617,16 +2617,18 @@
 (service
+Id
 , price)

Update LpPhoneMain