ResourceRate

using System;  using TestFramework.ApplicationAPI; using TestFramework.AuthenticateAPI;
using TestFramework;  namespace Tests.resource { 	/// <summary>
	/// Summary description for ResourceRate.
	/// 
	/// This sample create a resource rate and assigns
	/// it to a resource in RPM repository
	/// </summary>
	public class ResourceRate
	{
		public ResourceRate()
		{

		}

		//All these variables are used in this sample
		public static String resourceName = "IBM_testABCDEF";
		public static double rate = 50.00;
		public static double costph = 50.00;
		public static double sellingRateph = 60.00;
		public static double specialCostph = 75.00;
		public static double specialSellingRateph = 90.00;

		//Session ID is use for all transaction and is get from the 
		//Authenticate.login function. The session ID will replace 
		// the User password while transacting
		public static String sessionid = "";

		public void sampleTest()
		{

			// start the communication with the api
			sessionid = APISetup.SetUp();

			// create a resource object
			Resource res = new Resource();

			// create a resourceRate object
			ResourceRates rates = new ResourceRates();

			// create a resource Scope
			// to keep resource rates linked with resource
			ResourceScope rScope = new ResourceScope();
			rScope.resourceRates = true;

			// load resource from RPM repository
			// use resource Scope
			res = (Resource)APISetup.application.
				loadFromXpath(sessionid, 
				"/Resource[fullname='" + resourceName + "']", 
				rScope ).rpmObjectList[0];

			// initialize the resource rate object
			rates.regularCostPerHour  = costph;
			rates.sellingRatePerHour  = sellingRateph;
			rates.specialCostPerHour  = specialCostph;
			rates.specialSellingRatePerHour  = specialSellingRateph;
			
			// save the resource in the RPM repository
			// use the sessionid acquired in the setUp
			// use the resource scope
			 SaveResult save = APISetup.application.save(sessionid, 
				 res, rScope, ReloadType.None );
			APISetup.checkForErrors( save );


			// end the communication with the api.
			APISetup.CleanUp(sessionid);
		}

	}
}