﻿//Communicate with Cart Service.

function CropEditorProxy(icropEditor, iEditPhotoService) {
    this.cropEditor = icropEditor;
    this.editPhotoService = iEditPhotoService;
}

CropEditorProxy.prototype = {
    cropEditor: null,
    editPhotoService : null,
    
    //Web service call and handler pairs.
    
    getOrderItemCropWrappers: function(eOrderItemIds,maxThumbPhotoSize,maxPreviewPhotoSize){
        this.editPhotoService.GetOrderItemCropWrappers(eOrderItemIds, maxThumbPhotoSize, maxPreviewPhotoSize, this.getOrderItemCropWrappersComplete, OnError);
    },
    getOrderItemCropWrappersComplete: function(result) {
        this.cropEditor.populateCropAspectInfoComplete(result);
    },    
    
    
    saveOrderItemCrops: function(orderItemCropWrapperList) {
        this.editPhotoService.SaveCropDatas(orderItemCropWrapperList, this.saveOrderItemCropsComplete, OnError);
    },
    saveOrderItemCropsComplete: function(result) {
        if (result == false)
        {
            //alert('failed to save. Please wait 15 minutes and try again later.');
            //redirect("error.aspx");
        }
        this.cropEditor.saveOrderItemCropsComplete();
        //else can do a success msg popup anything.
    },
    
    
    getMinimumResOrderItemMedia: function (mediaID, rpid, currentAspectRatio) {
        this.editPhotoService.GetMinimumResOrderItemMedia(mediaID, rpid, currentAspectRatio, this.getMinimumResOrderItemMediaComplete, OnError);
    },
    getMinimumResOrderItemMediaComplete: function (result) {
        this.cropEditor.getMinimumResOrderItemMediaComplete(result);
    },
    
    
    clear: function() {
    }
};