Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
507 rajveer 1
/**
2
 * 
3
 */
4
package in.shop2020.serving.controllers;
5
 
6
import in.shop2020.model.v1.user.Address;
7
import in.shop2020.model.v1.user.AddressType;
555 chandransh 8
import in.shop2020.model.v1.user.User;
507 rajveer 9
import in.shop2020.model.v1.user.UserState;
10
import in.shop2020.serving.pages.PageContentKeys;
11
import in.shop2020.serving.pages.PageEnum;
12
import in.shop2020.serving.pages.PageManager;
13
import in.shop2020.serving.utils.Utils;
14
import in.shop2020.thrift.clients.UserContextServiceClient;
15
 
16
import java.io.UnsupportedEncodingException;
17
import java.util.Date;
18
import java.util.HashMap;
19
import java.util.Map;
20
 
21
import org.apache.juli.logging.Log;
22
import org.apache.juli.logging.LogFactory;
23
import org.apache.struts2.convention.annotation.Result;
24
import org.apache.struts2.convention.annotation.Results;
25
import org.apache.struts2.interceptor.ParameterAware;
26
import org.apache.struts2.rest.DefaultHttpHeaders;
27
import org.apache.struts2.rest.HttpHeaders;
28
 
29
/**
30
 * @author rajveer
31
 *
32
 */
33
 
517 rajveer 34
public class PersonalDetailsController extends BaseController 
507 rajveer 35
	implements ParameterAware {
36
 
37
 
38
	/**
39
	 * 
40
	 */
517 rajveer 41
	private static Log log = LogFactory.getLog(PersonalDetailsController.class);
507 rajveer 42
 
43
	private Map<String,String> htmlSnippets;
44
	/**
45
	 * 
46
	 */
47
 
48
 
49
	private Map<String, String[]> reqparams;
50
 
51
	private String id;
52
 
53
	private int action;
54
 
55
 
517 rajveer 56
	public PersonalDetailsController() {
507 rajveer 57
		super();
58
	}
59
 
60
    // POST /logindetails
61
    public String create() {
62
    	log.info("PersonaldetailsController.create");
63
 
64
 
65
		String name = this.request.getParameter("txtName");
569 rajveer 66
		String dateOfBirth = this.request.getParameter("dateOfBirth");
507 rajveer 67
		String sex = this.request.getParameter("sex");
68
		String communicationEmail = this.request.getParameter("txtCommEmail");
69
		String subscribeNewsletter = this.request.getParameter("subscribe");
70
 
71
		if(this.userinfo.isLoggedIn()){
569 rajveer 72
			if(Utils.UpdatePersonalDetails(userinfo.getUserId(), name, dateOfBirth,sex,communicationEmail,subscribeNewsletter))
507 rajveer 73
			{
74
				return "success";
75
			}
76
    	}
77
		return "failure";
78
    }
79
 
80
 
81
    // GET /test
82
    public HttpHeaders index() throws UnsupportedEncodingException {
83
    	log.info("this.request=" + this.request);
84
 
85
    	String userId = "";
86
 
87
    	if(this.userinfo.isLoggedIn()){
88
    		userId = (new Long(this.userinfo.getUserId())).toString();
89
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
90
			params.put(PageContentKeys.CUSTOMER_ID, userId);
91
			params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
555 chandransh 92
			params.put(PageContentKeys.USER_NAME, userinfo.getNameOfUser());
93
			params.put(PageContentKeys.IS_LOGGED_IN, userinfo.isLoggedIn()+"");
507 rajveer 94
 
95
			htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.PERSONAL_DETAILS_PAGE, params);
96
			return new DefaultHttpHeaders("index").disableCaching();
97
 
98
    	}else{
99
    		return new DefaultHttpHeaders("login").disableCaching();
100
    	}
101
 
102
    }
103
 
104
    public String getHeaderSnippet(){
105
		return htmlSnippets.get("HEADER");
106
	}
107
 
108
	public String getMainMenuSnippet(){
109
		return htmlSnippets.get("MAIN_MENU");
110
	}
111
 
112
	public String getSearchBarSnippet(){
113
		return htmlSnippets.get("SEARCH_BAR");
114
	}
115
 
116
 
117
	public String getCustomerServiceSnippet(){
118
		return htmlSnippets.get("CUSTOMER_SERVICE");
119
	}
120
 
121
	public String getMyaccountHeaderSnippet(){
122
		return htmlSnippets.get("MYACCOUNT_HEADER");
123
	}
124
 
125
	public String getPersonalDetailsSnippet(){
126
		return htmlSnippets.get("PERSONAL_DETAILS");
127
	}
128
 
129
	public String getMyResearchSnippet(){
130
		return htmlSnippets.get("MY_RESEARCH");
131
	}
132
 
133
	public String getFooterSnippet(){
134
		return htmlSnippets.get("FOOTER");
135
	}
136
 
137
	public String getJsFileSnippet(){
138
		return htmlSnippets.get("JS_FILES");
139
	}
140
 
141
	public String getCssFileSnippet(){
142
		return htmlSnippets.get("CSS_FILES");
143
	}
144
 
145
    /**
146
     * 
147
     * @param id
148
     */
149
    public void setId(String id) {
150
        this.id = id;
151
    }
152
 
153
 
154
    /**
155
     * 
156
     */
157
//    @Override
158
//	public void setServletRequest(HttpServletRequest request) {
159
//		this.request = request;
160
//	}
161
 
162
 
163
	@Override
164
	public void setParameters(Map<String, String[]> reqmap) {
165
		log.info("setParameters:" + reqmap);
166
 
167
		this.reqparams = reqmap;
168
	}
169
 
170
}