Subversion Repositories SmartDukaan

Rev

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

Rev 36394 Rev 36628
Line 434... Line 434...
434
    }
434
    }
435
 
435
 
436
    @RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
436
    @RequestMapping(value = "/schemes/update", method = RequestMethod.POST)
437
    public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
437
    public String updateShcemes(HttpServletRequest request, @RequestBody SchemeItems schemeItems, Model model)
438
            throws Exception {
438
            throws Exception {
-
 
439
        LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
439
        for (int schemeId : schemeItems.getSchemeIds()) {
440
        for (int schemeId : schemeItems.getSchemeIds()) {
440
            if (schemeRepository.selectById(schemeId) != null)
441
            Scheme scheme = schemeRepository.selectById(schemeId);
-
 
442
            if (scheme != null)
441
                for (int catalogId : schemeItems.getCatalogIds()) {
443
                for (int catalogId : schemeItems.getCatalogIds()) {
442
                    if (tagListingRepository.selectAllByCatalogIds(Arrays.asList(catalogId)).size() > 0) {
444
                    if (tagListingRepository.selectAllByCatalogIds(Arrays.asList(catalogId)).size() > 0) {
443
                        SchemeItem si = new SchemeItem();
-
 
444
                        si.setCatalogId(catalogId);
-
 
445
                        si.setSchemeId(schemeId);
-
 
446
                        si.setCreateTimestamp(LocalDateTime.now());
-
 
447
                        try {
445
                        try {
448
                            schemeItemRepository.persist(si);
446
                            schemeService.addSchemeItemWithDates(schemeId, catalogId,
-
 
447
                                    scheme.getStartDateTime(), scheme.getEndDateTime(), loginDetails.getFofoId());
449
                        } catch (Exception e) {
448
                        } catch (ProfitMandiBusinessException e) {
450
                            LOGGER.info("Scheme aleady exist");
449
                            LOGGER.info("Scheme already exists for schemeId={}, catalogId={}", schemeId, catalogId);
451
                        }
450
                        }
452
                        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
451
                        model.addAttribute("response1", mvcResponseSender.createResponseString(true));
453
                    } else {
452
                    } else {
454
                        LOGGER.info("Invalid catalog Id - {}", catalogId);
453
                        LOGGER.info("Invalid catalog Id - {}", catalogId);
455
                    }
454
                    }