Subversion Repositories SmartDukaan

Rev

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

Rev 35458 Rev 36539
Line 170... Line 170...
170
		customerAddressRepository.persist(customerAddress);
170
		customerAddressRepository.persist(customerAddress);
171
		return responseSender.ok(this.toCustomAddress(customerAddress));
171
		return responseSender.ok(this.toCustomAddress(customerAddress));
172
 
172
 
173
	}
173
	}
174
 
174
 
-
 
175
	@RequestMapping(value = "/customer/address/update", method = RequestMethod.PUT)
-
 
176
	public ResponseEntity<?> updateAddress(HttpServletRequest request, @RequestParam int addressId,
-
 
177
			@RequestBody CustomAddress customAddress) {
-
 
178
		try {
-
 
179
			CustomerAddress customerAddress = customerAddressRepository.selectById(addressId);
-
 
180
			if (customAddress.getName() != null) customerAddress.setName(customAddress.getName());
-
 
181
			if (customAddress.getLastName() != null) customerAddress.setLastName(customAddress.getLastName());
-
 
182
			if (customAddress.getLine1() != null) customerAddress.setLine1(customAddress.getLine1());
-
 
183
			if (customAddress.getLine2() != null) customerAddress.setLine2(customAddress.getLine2());
-
 
184
			if (customAddress.getLandmark() != null) customerAddress.setLandmark(customAddress.getLandmark());
-
 
185
			if (customAddress.getCity() != null) customerAddress.setCity(customAddress.getCity());
-
 
186
			if (customAddress.getPinCode() != null) customerAddress.setPinCode(customAddress.getPinCode());
-
 
187
			if (customAddress.getState() != null) customerAddress.setState(customAddress.getState());
-
 
188
			if (customAddress.getCountry() != null) customerAddress.setCountry(customAddress.getCountry());
-
 
189
			if (customAddress.getPhoneNumber() != null) customerAddress.setPhoneNumber(customAddress.getPhoneNumber());
-
 
190
			return responseSender.ok(this.toCustomAddress(customerAddress));
-
 
191
		} catch (ProfitMandiBusinessException e) {
-
 
192
			return responseSender.badRequest(e);
-
 
193
		}
-
 
194
	}
-
 
195
 
175
	private CustomerAddress toCustomerAddress(int customerId, CustomAddress customAddress) {
196
	private CustomerAddress toCustomerAddress(int customerId, CustomAddress customAddress) {
176
		CustomerAddress customerAddress = new CustomerAddress();
197
		CustomerAddress customerAddress = new CustomerAddress();
177
		customerAddress.setCustomerId(customerId);
198
		customerAddress.setCustomerId(customerId);
178
		customerAddress.setName(customAddress.getName());
199
		customerAddress.setName(customAddress.getName());
179
		customerAddress.setLastName(customAddress.getLastName());
200
		customerAddress.setLastName(customAddress.getLastName());