/// <reference path="ComplexWCFService.aspx" />
function onFailed(error)
{
    alert(error);
}


function businessEntitySave()
{
/*
    var entity = {"Address":$get("businessEntityAddress").value, "City":$get("businessEntityCity").value,
                    "State":$get("businessEntityState").value, "Zip":$get("businessEntityZip").value};
*/
    var entity = new AjaxWebServicesDemo.BusinessEntity();
    entity.Address = $get("businessEntityAddress").value;
    entity.City = $get("businessEntityCity").value;
    entity.State = $get("businessEntityState").value;
    entity.Zip = $get("businessEntityZip").value;

    tempuri.org.ComplexService.Save(entity,businessEntityOnSuccess,onFailed);
}

function businessEntityOnSuccess(result)
{
    $get("businessEntityId").innerHTML = result.Id;
}

function customerEntitySave()
{

// brak informacji o typie uniemożliwia określenie typu danych
/*
    var entity = {"FirstName":$get("customerEntityFirstName").value,"LastName":$get("customerEntityLastName").value, 
                    "Address":$get("customerEntityAddress").value, "City":$get("customerEntityCity").value,
                    "State":$get("customerEntityState").value, "Zip":$get("customerEntityZip").value};
*/
// type information helps serializer during converstion

    var entity = new AjaxWebServicesDemo.CustomerEntity();
    entity.FirstName = $get("customerEntityFirstName").value;
    entity.LastName = $get("customerEntityLastName").value;
    entity.Address = $get("customerEntityAddress").value;
    entity.City = $get("customerEntityCity").value;
    entity.State = $get("customerEntityState").value;
    entity.Zip = $get("customerEntityZip").value;
    
    tempuri.org.ComplexService.Save(entity,cutomerEntityOnSuccess,onFailed);


}

function cutomerEntityOnSuccess(result)
{
    $get("customerEntityId").innerHTML = result.Id;

}

function vendorEntitySave()
{
    // brak informacji o typie uniemożliwia określenie typu danych
    /*
    var entity = {"VendorName":$get("vendorEntityVendorName").value, 
                    "Address":$get("vendorEntityAddress").value, "City":$get("vendorEntityCity").value,
                    "State":$get("vendorEntityState").value, "Zip":$get("vendorEntityZip").value};
                    
    */

    //type information helps serializer during conversion
                  
    var entity = new AjaxWebServicesDemo.VendorEntity();
    entity.VendorName = $get("vendorEntityVendorName").value;
    entity.Address = $get("vendorEntityAddress").value;
    entity.City = $get("vendorEntityCity").value;
    entity.State = $get("vendorEntityState").value;
    entity.Zip = $get("vendorEntityZip").value;


    tempuri.org.ComplexService.Save(entity,vendorEntityOnSuccess,onFailed);
}

function vendorEntityOnSuccess(result)
{
    $get("vendorEntityId").innerHTML = result.Id;

}

