Subversion Repositories SmartDukaan

Rev

Rev 555 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 555 Rev 569
Line 88... Line 88...
88
			address.setEnabled(true);
88
			address.setEnabled(true);
89
			address.setType(AddressType.HOME);
89
			address.setType(AddressType.HOME);
90
			
90
			
91
			if(userinfo.isLoggedIn()){
91
			if(userinfo.isLoggedIn()){
92
				try {
92
				try {
93
					userClient.addAddressForUser(userinfo.getUserId(), address, (new Date()).getTime(), false);
93
					this.addressId = userClient.addAddressForUser(userinfo.getUserId(), address, false);
94
					// FIXME: This is a tortuous way of finding the id of the
-
 
95
					// last address that was added. Also, there is no guarantee
-
 
96
					// that the maxAddressId will hold the id of the address
-
 
97
					// that was just added. Instead, make addAddressForUser
-
 
98
					// return the id of the address that was just added.
-
 
99
					List<Address> addresses = userClient.getUserById(userinfo.getUserId()).getAddresses();
-
 
100
					long maxAddressId = 0;
-
 
101
					for(Address tempaddress: addresses){
-
 
102
						if(tempaddress.getId() > maxAddressId){
-
 
103
							maxAddressId = tempaddress.getId();
-
 
104
						}
-
 
105
					}
-
 
106
					this.addressId = maxAddressId;
-
 
107
					// to set the address in cart
94
					// to set the address in cart
108
					userClient.addAddressToCart(userinfo.getCartId(), maxAddressId);
95
					userClient.addAddressToCart(userinfo.getCartId(), this.addressId);
109
				} catch (Exception e) {
96
				} catch (Exception e) {
110
					e.printStackTrace();
97
					e.printStackTrace();
111
					return new DefaultHttpHeaders("failure");
98
					return new DefaultHttpHeaders("failure");
112
				}
99
				}
113
				
100