Subversion Repositories SmartDukaan

Rev

Go to most recent revision | 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");
66
		int month = Integer.parseInt(this.request.getParameter("month"));
67
		int day = Integer.parseInt(this.request.getParameter("day"));
68
		int year = Integer.parseInt(this.request.getParameter("year"));
69
		String sex = this.request.getParameter("sex");
70
		String communicationEmail = this.request.getParameter("txtCommEmail");
71
		String subscribeNewsletter = this.request.getParameter("subscribe");
72
 
73
		if(this.userinfo.isLoggedIn()){
74
			if(Utils.UpdatePersonalDetails(userinfo.getUserId(), name, month,day,year,sex,communicationEmail,subscribeNewsletter))
75
			{
76
				return "success";
77
			}
78
    	}
79
		return "failure";
80
    }
81
 
82
 
83
    // GET /test
84
    public HttpHeaders index() throws UnsupportedEncodingException {
85
    	log.info("this.request=" + this.request);
86
 
87
    	String userId = "";
88
 
89
    	if(this.userinfo.isLoggedIn()){
90
    		userId = (new Long(this.userinfo.getUserId())).toString();
91
			Map<PageContentKeys, String> params = new HashMap<PageContentKeys, String>();
92
			params.put(PageContentKeys.CUSTOMER_ID, userId);
93
			params.put(PageContentKeys.ITEM_COUNT, userinfo.getTotalItems()+"");
555 chandransh 94
			params.put(PageContentKeys.USER_NAME, userinfo.getNameOfUser());
95
			params.put(PageContentKeys.IS_LOGGED_IN, userinfo.isLoggedIn()+"");
507 rajveer 96
 
97
			htmlSnippets = PageManager.getPageManager().getPageContents(PageEnum.PERSONAL_DETAILS_PAGE, params);
98
			return new DefaultHttpHeaders("index").disableCaching();
99
 
100
    	}else{
101
    		return new DefaultHttpHeaders("login").disableCaching();
102
    	}
103
 
104
    }
105
 
106
    public String getHeaderSnippet(){
107
		return htmlSnippets.get("HEADER");
108
	}
109
 
110
	public String getMainMenuSnippet(){
111
		return htmlSnippets.get("MAIN_MENU");
112
	}
113
 
114
	public String getSearchBarSnippet(){
115
		return htmlSnippets.get("SEARCH_BAR");
116
	}
117
 
118
 
119
	public String getCustomerServiceSnippet(){
120
		return htmlSnippets.get("CUSTOMER_SERVICE");
121
	}
122
 
123
	public String getMyaccountHeaderSnippet(){
124
		return htmlSnippets.get("MYACCOUNT_HEADER");
125
	}
126
 
127
	public String getPersonalDetailsSnippet(){
128
		return htmlSnippets.get("PERSONAL_DETAILS");
129
	}
130
 
131
	public String getMyResearchSnippet(){
132
		return htmlSnippets.get("MY_RESEARCH");
133
	}
134
 
135
	public String getFooterSnippet(){
136
		return htmlSnippets.get("FOOTER");
137
	}
138
 
139
	public String getJsFileSnippet(){
140
		return htmlSnippets.get("JS_FILES");
141
	}
142
 
143
	public String getCssFileSnippet(){
144
		return htmlSnippets.get("CSS_FILES");
145
	}
146
 
147
    /**
148
     * 
149
     * @param id
150
     */
151
    public void setId(String id) {
152
        this.id = id;
153
    }
154
 
155
 
156
    /**
157
     * 
158
     */
159
//    @Override
160
//	public void setServletRequest(HttpServletRequest request) {
161
//		this.request = request;
162
//	}
163
 
164
 
165
	@Override
166
	public void setParameters(Map<String, String[]> reqmap) {
167
		log.info("setParameters:" + reqmap);
168
 
169
		this.reqparams = reqmap;
170
	}
171
 
172
}