package pages;

import java.io.Serializable;
import java.util.ArrayList;

import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

import baseClasses.Order.OrderStatus;
import baseClasses.Order;
import baseClasses.Page;
import baseClasses.Product;
import baseClasses.User;

/**
 * @author 
 *
 */

@Named
@SessionScoped
public class AddRemoveAdmin extends Page implements Serializable {
	
	private User admin = new User();
	private String uName;
	private String eMail;
	private String pWord;
	private ArrayList<Order> arr = new ArrayList<Order>();
	/**
	 * Default serialVersionID generated from eclipse
	 */
	private static final long serialVersionUID = 1L;
	
	public void test(){
		Product p = new Product("test","1", 123, "", "description", 100, 10);
		ArrayList<Product> arr = new ArrayList<Product>();
		arr.add(p);
		Order o = new Order(100,arr,"date",OrderStatus.IN_PROCESS);
		ArrayList<Order> arr2 = new ArrayList<Order>();
		arr2.add(o);
		User u = new User(0001, "test",arr2,"Testemail", "password", false);
		super.updateDB(u);
	}	
	public void setUName(String uName){
		this.uName = uName;
	} 
	public void setEMail(String eMail){
		this.eMail = eMail;
	}
	public void setPWord(String pWord){
		this.pWord = pWord;
	}
	public String getPWord(){
		return pWord;
	}
	public String getEMail(){
		return eMail;
	}
	public String getUName(){
		return uName;
	}
	
	public User getAdmin(){
		return admin;
	}
	
	public void setAdmin(User u){
		admin = u;
	}
	
	public void addUser(){ 
		admin.setAdmin(false);
		admin.setOrders(arr);
		super.insertDB(admin);
	}
	
	public void removeUser(String uName){
		super.updateDB("remove from webshopDB where name="+uName);
	} 
}
@@ -69,16 +69,40 @@
 ayList;%0D
+%0Aimport java.util.List;%0D
 %0A%0D%0Aimpor
@@ -611,16 +611,68 @@
 er%3E();%0D%0A
+%09private List%3CUser%3E users = new ArrayList%3CUser%3E();%0D%0A
 %09/**%0D%0A%09 
@@ -1171,16 +1171,86 @@
 (u);%0D%0A%09%7D
+%0D%0A%09%0D%0A    public List%3CUser%3E getUsers()%7B%0D%0A        return users;%0D%0A    %7D%0D%0A
 %09%0D%0A%09publ
@@ -1766,24 +1766,45 @@
 ders(arr);%0D%0A
+%09%09users.add(admin);%0D%0A
 %09%09super.inse
@@ -1932,8 +1932,9 @@
 %0D%0A%09%7D
- 
 %0D%0A%7D
+%0D%0A

Add admin works, but some major bugs appear