Subversion Repositories SmartDukaan

Rev

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

Rev 2145 Rev 2949
Line 53... Line 53...
53
			String sex = this.request.getParameter("sex");
53
			String sex = this.request.getParameter("sex");
54
			String communicationEmail = this.request.getParameter("txtCommEmail");
54
			String communicationEmail = this.request.getParameter("txtCommEmail");
55
			String subscribeNewsletter = this.request.getParameter("subscribe");
55
			String subscribeNewsletter = this.request.getParameter("subscribe");
56
			String phone = this.request.getParameter("txtPhone");
56
			String phone = this.request.getParameter("txtPhone");
57
			
57
			
58
			if(UpdatePersonalDetails(userinfo.getUserId(), name, phone, dateOfBirth, sex,communicationEmail,subscribeNewsletter))
58
			if(updatePersonalDetails(userinfo.getUserId(), name, phone, dateOfBirth, sex,communicationEmail,subscribeNewsletter))
59
			{	
59
			{	
60
				addActionMessage("Your personal details updated");
60
				addActionMessage("Your personal details updated");
61
				return "success";
61
				return "success";
62
			}
62
			}
63
    	}
63
    	}
Line 77... Line 77...
77
    		return "redirect";
77
    		return "redirect";
78
    	}
78
    	}
79
    	
79
    	
80
    }
80
    }
81
    
81
    
82
	private boolean UpdatePersonalDetails(long userId,  String name,  String phone, String dateOfBirth, String sex, String communicationEmail,
82
	private boolean updatePersonalDetails(long userId,  String name,  String phone, String dateOfBirth, String sex, String communicationEmail,
83
			String subscribeNewsletter) {
83
			String subscribeNewsletter) {
84
		
84
		
85
		try {
85
		try {
86
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
86
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
87
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
87
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
88
 
-
 
89
			
88
			
90
			User user = userClient.getUserById(userId);		
89
			User user = userClient.getUserById(userId);		
91
			user.setDateOfBirth(dateOfBirth);
90
			user.setDateOfBirth(dateOfBirth);
92
			user.setName(name);
91
			user.setName(name);
93
			user.setCommunicationEmail(communicationEmail);
92
			user.setCommunicationEmail(communicationEmail);
94
			try {
93
			try {
95
			    user.setSex(Sex.findByValue(Integer.parseInt(sex)));
94
			    user.setSex(Sex.findByValue(Integer.parseInt(sex)));
96
			}
-
 
97
			catch (NumberFormatException e) {
95
			} catch (NumberFormatException e) {
98
				e.printStackTrace();
96
				log.warn("Unable to parse the value of sex", e);
99
			}
97
			}
100
			user.setMobileNumber(phone);
98
			user.setMobileNumber(phone);
101
			userClient.updateUser(user);
99
			userClient.updateUser(user);
102
			
100
			
103
			return true;
101
			return true;
104
		} catch (UserContextException e) {
102
		} catch (UserContextException e) {
105
			e.printStackTrace();
103
			log.error("Unable to get or update the personal details:", e);
106
		} catch (TException e) {
104
		} catch (TException e) {
107
			e.printStackTrace();
105
		    log.error("Unable to get or update the personal details:", e);
108
		} catch (Exception e) {
106
		} catch (Exception e) {
109
			e.printStackTrace();
107
		    log.error("Unable to get or update the personal details:", e);
110
		}
108
		}
111
		return false;
109
		return false;
112
	}
110
	}
113
 
-
 
114
 
-
 
115
 
-
 
116
    
111
    
117
    public Map<String, String> getVelocityParams(){
112
    public Map<String, String> getVelocityParams(){
118
    	UserContextServiceClient userContextServiceClient = null;
113
    	UserContextServiceClient userContextServiceClient = null;
119
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
114
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
120
		try{
115
		try{
Line 127... Line 122...
127
			velocityParams.put("sex", user.getSex().getValue()+"");
122
			velocityParams.put("sex", user.getSex().getValue()+"");
128
			velocityParams.put("name", user.getName());
123
			velocityParams.put("name", user.getName());
129
			velocityParams.put("phone", user.getMobileNumber());
124
			velocityParams.put("phone", user.getMobileNumber());
130
			velocityParams.put("dateOfBirth", user.getDateOfBirth());
125
			velocityParams.put("dateOfBirth", user.getDateOfBirth());
131
		}catch (Exception e){
126
		}catch (Exception e){
132
			e.printStackTrace();
127
			log.error("Unable to get user from the user context service", e);
133
		}
128
		}
134
		return velocityParams;
129
		return velocityParams;
135
	}
130
	}
136
    
131
    
137
    public String getMyaccountHeaderSnippet(){
132
    public String getMyaccountHeaderSnippet(){