I wrote this function:
public string CreateAttribute(String ProdID, int counter)
{
bool fireAgain = false;
String strProdID = ProdID;
String strFund = "";
String strAppeal = "";
String strPackage = "";
int cnt = counter;
// Build WC API complete URL
string wcApiCompleteUrl = Variables.WCAPIBaseUrl + "/" + "products/" + strProdID + "/?" + "consumer_key=" + Variables.WCAPIConsumerKey + "&consumer_secret=" + Variables.WCAPIConsumerSecret;
// Just some kind of debug output :-)
ComponentMetaData.FireInformation(10, "Start - URL", String.Format("The following URL has been used: {0}", wcApiCompleteUrl), "", 0, fireAgain);
try
{
//Call getWebServiceResult to return our WorkGroupMetric array
WCProduct[] wcProductOutput = GetRestServiceResult1(wcApiCompleteUrl);
////For each group of metrics output records
foreach (var wcProducts in wcProductOutput)
{
if (wcProducts.Attributes.Length == 0)
{
strFund = "NONE";
strAppeal = "NONE";
strPackage = "NONE";
}
else
{
foreach (var wcAttribute in wcProducts.Attributes)
{
if (wcAttribute.NameID == "Re-fund-member")
{
strFund = wcAttribute.options;
}
if (wcAttribute.NameID == "Re-appeal-code")
{
strAppeal = wcAttribute.options;
}
if (wcAttribute.NameID == "Re-package-code")
{
strPackage = wcAttribute.options;
}
}
}
}
if (cnt == 1)
{
return strFund;
}
if (cnt == 2)
{
return strAppeal;
}
if (cnt == 3)
{
return strPackage;
}
}
catch (Exception e)
{
FailComponent(e.ToString());
return "";
}
}
The purpose of the function is simple. It has to return me Fund Name or Appeal Code or Package Code. Just one for each Function Call. What should be return depends on counter. I am getting error: "Error 2 'ScriptMain.CreateAttribute(string, int)': not all code paths return a value C:\Users\rk688\AppData\Local\Temp\Vsta\SSIS_SC110\Vsta8rFSQ3hMmUy6TnLDJtcY8A\VstaSni__1__r7kUeV_uk8CyqoXQ\main.cs 360 19 SC_62c91189374d4fd6b180997972364e08" I cannot figure out what is wrong with the function. Can you help?