Subversion Repositories SmartDukaan

Rev

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

Rev 11511 Rev 11514
Line 158... Line 158...
158
 
158
 
159
    // DELETE /entity
159
    // DELETE /entity
160
    public String destroy() {
160
    public String destroy() {
161
        if(id > 0)  {
161
        if(id > 0)  {
162
            try {
162
            try {
163
                UserClient userContextServiceClient = new UserClient();
-
 
164
                in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
165
 
-
 
166
                userClient.deleteItemFromCart(id, itemId);
163
                userClient.deleteItemFromCart(id, itemId);
167
                return index();
164
                return index();
168
            } catch (ShoppingCartException e) {
165
            } catch (ShoppingCartException e) {
169
                log.error("Unable to delete item from cart: ", e);
166
                log.error("Unable to delete item from cart: ", e);
170
                errorMsg = "Unable to delete item. Please try again.";
167
                errorMsg = "Unable to delete item. Please try again.";
Line 192... Line 189...
192
        return index();
189
        return index();
193
    }
190
    }
194
    
191
    
195
    private boolean updateItemQuantityInCart(long cartId, long itemId, long quantity){
192
    private boolean updateItemQuantityInCart(long cartId, long itemId, long quantity){
196
        try {
193
        try {
197
            UserClient userContextServiceClient = new UserClient();
-
 
198
            in.shop2020.model.v1.user.UserContextService.Client userClient = userContextServiceClient.getClient();
-
 
199
 
-
 
200
            userClient.addItemToCart(cartId, itemId, quantity, -1);
194
            userClient.addItemToCart(cartId, itemId, quantity, -1);
201
            return true;
195
            return true;
202
        } catch (ShoppingCartException e) {
196
        } catch (ShoppingCartException e) {
203
            log.error("Unable to update the item quantity in the cart: ", e);
197
            log.error("Unable to update the item quantity in the cart: ", e);
204
            errorMsg = "Unable to change quantity. Please try again.";
198
            errorMsg = "Unable to change quantity. Please try again.";
Line 213... Line 207...
213
    }
207
    }
214
           
208
           
215
    public String insureItem() {
209
    public String insureItem() {
216
        insuranceResult = "";
210
        insuranceResult = "";
217
        try {
211
        try {
218
            UserContextService.Client usc = new UserClient().getClient();
-
 
219
            if(usc.insureItem(itemId, id, toInsure, insuranceType)) {
212
            if(userClient.insureItem(itemId, id, toInsure, insuranceType)) {
220
                setInsuranceResult("SUCCESS");
213
                setInsuranceResult("SUCCESS");
221
            } else {
214
            } else {
222
                setInsuranceResult("FAILURE");
215
                setInsuranceResult("FAILURE");
223
            }
216
            }
224
        } catch (Exception e) {
217
        } catch (Exception e) {
Line 228... Line 221...
228
        return "insurance-result";
221
        return "insurance-result";
229
    }
222
    }
230
    
223
    
231
    public String edit()  {
224
    public String edit()  {
232
        String action = request.getParameter("action");
225
        String action = request.getParameter("action");
233
        UserClient userServiceClient = null;
-
 
234
        PromotionClient promotionServiceClient = null;
226
        PromotionClient promotionServiceClient = null;
235
        try {
227
        try {
236
            if(action == null || action.isEmpty())  {
228
            if(action == null || action.isEmpty())  {
237
                errorMsg = "Invalid Request Action";
229
                errorMsg = "Invalid Request Action";
238
                return index();
230
                return index();
Line 250... Line 242...
250
                
242
                
251
                promotionClient.applyCoupon(couponCode, id);
243
                promotionClient.applyCoupon(couponCode, id);
252
                
244
                
253
            }
245
            }
254
            else if (action.equals("removecoupon"))    {
246
            else if (action.equals("removecoupon"))    {
255
                userServiceClient = new UserClient();
-
 
256
                UserContextService.Client userClient = userServiceClient.getClient();
-
 
257
                userClient.removeCoupon(id);
247
                userClient.removeCoupon(id);
258
            }
248
            }
259
        } catch (PromotionException e) {
249
        } catch (PromotionException e) {
260
            log.info("Invalid coupon: " + e.getMessage());
250
            log.info("Invalid coupon: " + e.getMessage());
261
            errorMsg = "Invalid coupon : " + e.getMessage();
251
            errorMsg = "Invalid coupon : " + e.getMessage();