コード例 #1
0
  @RequestMapping(value = "/addDriver")
  public ModelAndView addDriver(HttpServletRequest request) {
    ModelAndView mnv = new ModelAndView("viewsTransport/adminPages/driverManipulation");

    String driverName = request.getParameter("driverName");
    String driverMobNumber = request.getParameter("driverMobileNumber");

    if (driverName != null
        && !driverName.trim().equals("")
        && driverMobNumber != null
        && !driverMobNumber.trim().equals("")) {
      DriverUpdated driverUpdated = new DriverUpdated();
      driverUpdated.setDriverName(driverName);
      driverUpdated.setDriverMobileNumber(driverMobNumber);

      transportServiceUpdated.saveDriver(driverUpdated);
      mnv.addObject("status", "Driver added successfully");

      mnv.addObject("request", "modifyDriver");
      List<DriverUpdated> listOfDriverUpdated = transportServiceUpdated.getAllDriver();
      mnv.addObject("listOfDriverUpdated", listOfDriverUpdated);

    } else {
      mnv.addObject(
          "status", "Some Mandatory Parameters are missing, Please provide to Save Driver...");
    }

    return mnv;
  }
コード例 #2
0
  @RequestMapping(value = "/modifyDriver")
  public ModelAndView modifyDriver(HttpServletRequest request) {
    ModelAndView mnv = new ModelAndView("viewsTransport/adminPages/driverManipulation");

    String driverId = request.getParameter("driverId");

    if (driverId != null && !driverId.trim().equals("")) {
      DriverUpdated driverUpdated =
          transportServiceUpdated.getDriverByDriverId(Long.parseLong(driverId));

      if (driverUpdated != null) {
        String driverName = request.getParameter("driverName");
        String driverMobNumber = request.getParameter("driverMobileNumber");

        if (driverName != null
            && !driverName.trim().equals("")
            && driverMobNumber != null
            && !driverMobNumber.trim().equals("")) {

          driverUpdated.setDriverName(driverName);
          driverUpdated.setDriverMobileNumber(driverMobNumber);

          boolean driverUpdateFlag = transportServiceUpdated.updateDriver(driverUpdated);

          mnv.addObject("request", "modifyDriver");
          List<DriverUpdated> listOfDriverUpdated = transportServiceUpdated.getAllDriver();
          mnv.addObject("listOfDriverUpdated", listOfDriverUpdated);

          if (driverUpdateFlag) {
            mnv.addObject("status", "Driver modified Successfully");
          } else {
            mnv.addObject("status", "Error while modifying Driver, Please try again.");
          }

        } else {
          mnv.addObject("status", "Illegal Parameters provided for modifying Driver details...");
        }

      } else {
        mnv.addObject("status", "No Driver Found by Given Name");
      }
    } else {
      mnv.addObject("status", "Illegal Parameters provided for modifying Driver details...");
    }

    return mnv;
  }