Package com.ateam.webstore.handlers

Source Code of com.ateam.webstore.handlers.ShippingCodeHandler

package com.ateam.webstore.handlers;

import java.util.ArrayList;
import java.util.Collection;

import javax.servlet.http.HttpServletRequest;

import com.ateam.webstore.model.ShippingCode;
import com.ateam.webstore.service.impl.ShippingCodeService;

public class ShippingCodeHandler extends Handler {
  ShippingCodeService service;
 
  public ShippingCodeHandler(HttpServletRequest req) {
    super(req);
    service = new ShippingCodeService();
  }

  /**
   *
   * @return
   */
  public Collection<ShippingCode> getShippingCodes() {
//    Collection<ShippingCode> codes = new ArrayList<ShippingCode>();
//   
//    ShippingCode code1 = new ShippingCode(1, "UPS Ground", null);
//    codes.add(code1);
//    ShippingCode code2 = new ShippingCode(2, "UPS Next Day", null);
//    codes.add(code2);
    return service.getAll();
  }

  /**
   *
   * @return
   */
  public Collection<ShippingCode> getShippingCodes(int qty) {
   
    Collection<ShippingCode> codes = new ArrayList<ShippingCode>();
    for (ShippingCode c : getShippingCodes()) {
      if (c.getItemQty() == qty) {
        codes.add(c);
      }
    }
    return codes;
  }
 
  /**
   *
   * @param parseInt
   * @return
   */
  public ShippingCode getShippingCode() {
   
    Integer id = Integer.parseInt(req.getParameter(Parameters.SHIPPING_CODE.getId()));
   
    l.fine("get shipping code id:"+id);
    //ShippingCode code = new ShippingCode(2, "UPS Next Day", null);
   
    return service.getById(id);
  }

}
TOP

Related Classes of com.ateam.webstore.handlers.ShippingCodeHandler

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.