Subversion Repositories SmartDukaan

Rev

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

Rev 650 Rev 762
Line 1... Line 1...
1
/**
1
/**
2
 * 
2
 * 
3
 */
3
 */
4
package in.shop2020.serving.controllers;
4
package in.shop2020.serving.controllers;
5
 
5
 
-
 
6
import in.shop2020.model.v1.user.Sex;
6
import in.shop2020.model.v1.user.User;
7
import in.shop2020.model.v1.user.User;
-
 
8
import in.shop2020.model.v1.user.UserContextException;
7
import in.shop2020.serving.utils.Utils;
9
import in.shop2020.serving.utils.Utils;
8
import in.shop2020.thrift.clients.UserContextServiceClient;
10
import in.shop2020.thrift.clients.UserContextServiceClient;
9
 
11
 
10
import java.io.UnsupportedEncodingException;
12
import java.io.UnsupportedEncodingException;
11
import java.util.HashMap;
13
import java.util.HashMap;
Line 13... Line 15...
13
 
15
 
14
import org.apache.juli.logging.Log;
16
import org.apache.juli.logging.Log;
15
import org.apache.juli.logging.LogFactory;
17
import org.apache.juli.logging.LogFactory;
16
import org.apache.struts2.convention.annotation.Result;
18
import org.apache.struts2.convention.annotation.Result;
17
import org.apache.struts2.convention.annotation.Results;
19
import org.apache.struts2.convention.annotation.Results;
-
 
20
import org.apache.thrift.TException;
18
 
21
 
19
/**
22
/**
20
 * @author rajveer
23
 * @author rajveer
21
 *
24
 *
22
 */
25
 */
Line 52... Line 55...
52
			String sex = this.request.getParameter("sex");
55
			String sex = this.request.getParameter("sex");
53
			String communicationEmail = this.request.getParameter("txtCommEmail");
56
			String communicationEmail = this.request.getParameter("txtCommEmail");
54
			String subscribeNewsletter = this.request.getParameter("subscribe");
57
			String subscribeNewsletter = this.request.getParameter("subscribe");
55
			String phone = this.request.getParameter("txtPhone");
58
			String phone = this.request.getParameter("txtPhone");
56
			
59
			
57
			if(Utils.UpdatePersonalDetails(userinfo.getUserId(), name, phone, dateOfBirth, sex,communicationEmail,subscribeNewsletter))
60
			if(UpdatePersonalDetails(userinfo.getUserId(), name, phone, dateOfBirth, sex,communicationEmail,subscribeNewsletter))
58
			{	
61
			{	
59
				addActionMessage("Your personal details updated");
62
				addActionMessage("Your personal details updated");
60
				return "success";
63
				return "success";
61
			}
64
			}
62
    	}
65
    	}
Line 76... Line 79...
76
    		return "redirect";
79
    		return "redirect";
77
    	}
80
    	}
78
    	
81
    	
79
    }
82
    }
80
    
83
    
-
 
84
	private boolean UpdatePersonalDetails(long userId,  String name,  String phone, String dateOfBirth, String sex, String communicationEmail,
-
 
85
			String subscribeNewsletter) {
-
 
86
		
-
 
87
		try {
-
 
88
			UserContextServiceClient userContextServiceClient = new UserContextServiceClient();
-
 
89
			in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
90
 
-
 
91
			
-
 
92
			User user = userClient.getUserById(userId);		
-
 
93
			user.setDateOfBirth(dateOfBirth);
-
 
94
			user.setName(name);
-
 
95
			user.setCommunicationEmail(communicationEmail);
-
 
96
			user.setSex(Sex.findByValue(Integer.parseInt(sex)));
-
 
97
			user.setMobileNumber(phone);
-
 
98
			userClient.updateUser(user);
-
 
99
			
-
 
100
			return true;
-
 
101
		} catch (UserContextException e) {
-
 
102
			e.printStackTrace();
-
 
103
		} catch (TException e) {
-
 
104
			e.printStackTrace();
-
 
105
		} catch (Exception e) {
-
 
106
			e.printStackTrace();
-
 
107
		}
-
 
108
		return false;
-
 
109
	}
-
 
110
 
-
 
111
 
-
 
112
 
81
    
113
    
82
    public Map<String, String> getVelocityParams(){
114
    public Map<String, String> getVelocityParams(){
83
    	UserContextServiceClient userContextServiceClient = null;
115
    	UserContextServiceClient userContextServiceClient = null;
84
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
116
		in.shop2020.model.v1.user.UserContextService.Client userClient = null;
85
		try{
117
		try{