@RequestMapping(value = "/productDetail")
 public ModelAndView productDetail(@RequestParam(value = "id") int id, HttpSession session) {
   ModelAndView mv = new ModelAndView("productDetail");
   mv.addObject("productDetail", productSrv.getById(id));
   mv.addObject("listOfBrands", brandSrv.getAllBrands());
   if (session.getAttribute("cartSize") == null) {
     mv.addObject("cartSize", 0);
   } else {
     mv.addObject("cartSize", session.getAttribute("cartSize"));
   }
   return mv;
 }
 @RequestMapping("home")
 public ModelAndView homePage(HttpSession session) {
   ModelAndView mv = new ModelAndView("index");
   mv.addObject("brandList", brandSrv.getAllBrands());
   mv.addObject("newProductsList", productSrv.getNewArrivals());
   if (session.getAttribute("cartSize") == null) {
     mv.addObject("cartSize", 0);
   } else {
     mv.addObject("cartSize", session.getAttribute("cartSize"));
   }
   return mv;
 }
 @RequestMapping(value = "/showProductList")
 public ModelAndView productlist(@RequestParam(value = "id") int id, HttpSession session) {
   ModelAndView mv = new ModelAndView("productList");
   mv.addObject("brandList", brandSrv.getById(id));
   Brand brand = brandSrv.getById(id);
   int foundProducts = 0;
   Set<Category> cats = brand.getCategory();
   Iterator<Category> itr = cats.iterator();
   while (itr.hasNext()) {
     Category cat = itr.next();
     foundProducts += cat.getProduct().size();
   }
   mv.addObject("foundSize", foundProducts);
   mv.addObject("isUserClickBrand", "true");
   mv.addObject("listOfBrands", brandSrv.getAllBrands());
   setLists(mv);
   if (session.getAttribute("cartSize") == null) {
     mv.addObject("cartSize", 0);
   } else {
     mv.addObject("cartSize", session.getAttribute("cartSize"));
   }
   return mv;
 }
  @RequestMapping(value = "/", method = RequestMethod.GET)
  public ModelAndView indexPage(HttpSession session, HttpServletRequest request) {
    ModelAndView mv = new ModelAndView("index");
    mv.addObject("brandList", brandSrv.getAllBrands());
    mv.addObject("newProductsList", productSrv.getNewArrivals());
    if (session.getAttribute("cartSize") == null) {
      mv.addObject("cartSize", 0);
    } else {
      mv.addObject("cartSize", session.getAttribute("cartSize"));
    }

    try {
      if (request.getUserPrincipal().getName() != null) {
        userDetail = userDetailSrv.getByEmailID(request.getUserPrincipal().getName());
        System.out.println("UserName:-" + userDetail.getUser_fname());
        if (userDetail.getUserRole().getUser_role_id() == 1) {
          // mv.addObject("isAdminTrue",request.getUserPrincipal().getName());
          session.setAttribute("userId", userDetail.getUser_id());
          session.setAttribute(
              "username", (userDetail.getUser_fname() + " " + userDetail.getUser_lname()));
          System.out.println("Name:-" + userDetail.getUser_fname());
        } else {
          //	mv.addObject("isUserTrue",request.getUserPrincipal().getName());
          session.setAttribute("userId", userDetail.getUser_id());
          session.setAttribute(
              "username", (userDetail.getUser_fname() + " " + userDetail.getUser_lname()));
          System.out.println("Name:-" + userDetail.getUser_fname());
        }
      } else {

      }

    } catch (Exception e) {

    }
    return mv;
  }
  @RequestMapping(value = "/productListByFilterID")
  public ModelAndView productListByCatId(
      @RequestParam(value = "id") int id,
      @RequestParam(value = "bid") int bid,
      @RequestParam(value = "index") int index,
      HttpSession session) {
    ModelAndView mv = new ModelAndView("productList");
    mv.addObject("isUserClickByFilterID", "true");
    mv.addObject("listOfBrands", brandSrv.getAllBrands());
    if (session.getAttribute("cartSize") == null) {
      mv.addObject("cartSize", 0);
    } else {
      mv.addObject("cartSize", session.getAttribute("cartSize"));
    }

    int foundProducts = 0;
    if (index == 0) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", categorySrv.getById(id));
      try {
        Category category = categorySrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 1) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", productSizeSrv.getById(id));
      try {
        ProductSize category = productSizeSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 2) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameColorSrv.getById(id));
      try {
        FrameColor category = frameColorSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }
    } else if (index == 3) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameMaterialSrv.getById(id));
      try {
        FrameMaterial category = frameMaterialSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 4) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", frameTypeSrv.getById(id));
      try {
        FrameType category = frameTypeSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 5) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", lensColorSrv.getById(id));
      try {
        LensColor category = lensColorSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {

      }

    } else if (index == 6) {
      mv.addObject("indexNumber", index);
      mv.addObject("resultList", lensMaterialSrv.getById(id));
      try {
        LensMaterial category = lensMaterialSrv.getById(id);
        Set<Product> product = category.getProduct();
        Iterator<Product> itr = product.iterator();
        while (itr.hasNext()) {
          Product prd = itr.next();
          foundProducts++;
        }
      } catch (Exception e) {
      }
    }

    mv.addObject("brandList", brandSrv.getById(bid));
    mv.addObject("foundSize", foundProducts);
    setLists(mv);
    return mv;
  }