package service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import dao.PlatformDao;
import model.Offer;
import model.Request;

@Service("PlatformServiceImp")
public class PlatformServiceImp implements PlatformService {

	@Resource(name = "PlatformDaoImp")
	private PlatformDao PlatformDaoImp;

	@Override
	public Boolean removeExchange(Integer request_id, Integer user_from) {
		Boolean flag = PlatformDaoImp.removeExchange(request_id, user_from);
		System.out.println("flag: " + flag);
		return flag;
	}

	@Override
	public Boolean declineExchange(Integer request_id, Integer user_to) {
		Boolean flag = PlatformDaoImp.declineExchange(request_id, user_to);
		System.out.println("flag: " + flag);
		return flag;
	}

	@Override
	public Boolean removeOffer(Integer offer_id, Integer user_id) {
		Boolean flag = PlatformDaoImp.removeOffer(offer_id, user_id);
		System.out.println("flag: " + flag);
		return flag;
	}

	@Override
	public List<Request> showLatestTransaction(Integer sellerFrom, Integer sellerTo) {
		List<Request> requests = PlatformDaoImp.showLatestTransaction(sellerFrom, sellerTo);
		return requests;
	}

	@Override
	public List<Offer> searchExcahnge(Integer sellerFrom, Integer sellerTo, Integer pointsFrom, Integer pointsToMin) {
		List<Offer> offers = PlatformDaoImp.searchExcahnge(sellerFrom, sellerTo, pointsFrom, pointsToMin);
		return offers;
	}

	@Override
	public List<Offer> showRecommendationList(Integer sellerFrom, Integer sellerTo, Integer pointsFrom,
			Integer pointsToMin) {
		List<Offer> offers = PlatformDaoImp.showRecommendationList(sellerFrom, sellerTo, pointsFrom, pointsToMin);
		return offers;
	}

	@Override
	public Boolean updateOfferStatus(Integer offer_id, Integer user_from) {
		Boolean flag = PlatformDaoImp.updateOfferStatus(offer_id, user_from);
		System.out.println("flag: " + flag);
		return flag;
	}

	@Override
	public Boolean updateRequestStatus(Integer request_id, Integer user_from) {
		Boolean flag = PlatformDaoImp.updateRequestStatus(request_id, user_from);
		System.out.println("flag: " + flag);
		return flag;

	}

	@Override
	public Boolean acceptRequest(Integer request_id)
	{
		Boolean flag = PlatformDaoImp.acceptRequest(request_id);
		System.out.println("flag: " + flag);
		return flag;	
	}
}

@@ -2195,26 +2195,411 @@
 _id)
-%0A%09%7B%0A%09%09Boolean flag
+ %7B%0A%09%09Request request = new Request();%0A%09%09Integer UserFrom = request.getUserFrom();%0A%09%09Integer UserTo = request.getUserTo();%0A%09%09Integer PointsFrom = request.getPointsFrom();%0A%09%09Integer PointsTo = request.getPointsTo();%0A%09%09Integer SellerFrom = request.getSellerFrom();%0A%09%09Integer SellerTo = request.getSellerTo();%0A%09%09Integer OfferFrom = request.getOfferFrom();%0A%09%09Integer OfferTo = request.getOfferTo();%0A%09%09request
  = P
@@ -2612,29 +2612,27 @@
 mDaoImp.
-acceptR
+r
 equest
+Data
 (request
@@ -2643,60 +2643,535 @@
 ;%0A%09%09
-System.out.println(%22flag: %22 + flag);%0A%09%09return flag;%09
+// Boolean success = PlatformDaoImp.sendExchangeToBC(Integer request_id,%0A%09%09// Integer UserFrom, Integer UserTo,%0A%09%09// Integer PointsFrom, Integer PointsTo, Integer SellerFrom, Integer%0A%09%09// SellerTo);%0A%09%09Boolean success = true;%0A%09%09// call notification notifi(OfferFrom) notifi(OfferTo) notifi(UserFrom)%0A%09%09// notifi(UserTo)%0A%09%09Boolean acc = PlatformDaoImp.acceptRequest(request_id, OfferFrom, OfferTo);%0A%09%09List%3CInteger%3E requestList = PlatformDaoImp.listOfRequest(OfferFrom, OfferTo);%0A%09%09requestList.remove(request_id);%0A%0A%09%09return null;%0A
 %0A%09%7D%0A

Update PlatformServiceImp.java