Subversion Repositories SmartDukaan

Rev

Rev 1623 | Rev 1747 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1623 Rev 1625
Line 79... Line 79...
79
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient
79
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient
80
					.getClient();
80
					.getClient();
81
			User user = userClient.authenticateUser(email, encryptedPassword);
81
			User user = userClient.authenticateUser(email, encryptedPassword);
82
			userClient.setUserAsLoggedIn(user.getUserId(),(new Date()).getTime());
82
			userClient.setUserAsLoggedIn(user.getUserId(),(new Date()).getTime());
83
			String pincode = userClient.getDefaultPincode(user.getUserId());
83
			String pincode = userClient.getDefaultPincode(user.getUserId());
84
			userinfo.setUserId(user.getUserId());
-
 
85
			userinfo.setNameOfUser(user.getName());
-
 
86
			userinfo.setEmail(email);
-
 
87
			userinfo.setLoggedIn(true);
-
 
88
			userinfo.setPincode(pincode);
-
 
89
 
84
 
90
			// TODO: setTotalItems shouldn't be a method on userinfo. This allows
85
			// TODO: setTotalItems shouldn't be a method on userinfo. This allows
91
			// for potentially updating the item count wrongly. The method setCartId
86
			// for potentially updating the item count wrongly. The method setCartId
92
			// should update the item count as well. Also, there can be a method
87
			// should update the item count as well. Also, there can be a method
93
			// called refreshItemCount() that automatically updates the number of
88
			// called refreshItemCount() that automatically updates the number of
94
			// items currently in the cart.
89
			// items currently in the cart.
95
			if(userinfo.getCartId() != -1){
90
			if(userinfo.getUserId() != -1){
96
				userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
91
				userClient.mergeCart(userinfo.getCartId(), user.getActiveCartId());
-
 
92
				
97
				Widget browseHistory = userClient.getBrowseHistory(userinfo.getCartId());
93
				Widget browseHistory = userClient.getBrowseHistory(userinfo.getUserId());
98
				if(browseHistory != null){
94
				if(browseHistory != null){
99
					List<WidgetItem> items =  browseHistory.getItems();
95
					List<WidgetItem> items =  browseHistory.getItems();
100
					if(items != null){
96
					if(items != null){
101
						for(WidgetItem item: items){
97
						for(WidgetItem item: items){
102
							userClient.updateBrowseHistory(user.getUserId(), item.getItem_id());
98
							userClient.updateBrowseHistory(user.getUserId(), item.getItem_id());
103
						}
99
						}
104
					}
100
					}
105
				}
101
				}
-
 
102
				
-
 
103
				Widget myResearch = userClient.getMyResearch(userinfo.getUserId());
-
 
104
				if(myResearch != null){
-
 
105
					List<WidgetItem> items =  myResearch.getItems();
-
 
106
					if(items != null){
-
 
107
						for(WidgetItem item: items){
-
 
108
							userClient.updateMyResearch(user.getUserId(), item.getItem_id());
-
 
109
						}
-
 
110
					}
-
 
111
				}
106
			}
112
			}
107
			
113
			
108
			
114
			
-
 
115
			userinfo.setUserId(user.getUserId());
-
 
116
			userinfo.setNameOfUser(user.getName());
-
 
117
			userinfo.setEmail(email);
-
 
118
			userinfo.setLoggedIn(true);
-
 
119
			userinfo.setPincode(pincode);
109
			userinfo.setCartId(user.getActiveCartId());
120
			userinfo.setCartId(user.getActiveCartId());
110
			int totalItems = userClient.getCart(user.getActiveCartId())
121
			int totalItems = userClient.getCart(user.getActiveCartId())
111
					.getLinesSize();
122
					.getLinesSize();
112
			userinfo.setTotalItems(totalItems);
123
			userinfo.setTotalItems(totalItems);
113
			System.out.println(userinfo);
124
			System.out.println(userinfo);