I wrote the following function, but I am getting an error that says "not all code paths return a value". I've looked this up online and searched through questions on stack overflow, but I just can see what I'm missing / doing wrong.
I am trying to use this function in an if statement elsewhere that checks if this function returns true or false. If true, it will do work. If false, it will return an error to the user.
private bool IsStatusChangeValid(CommandResult result)
{
var file = FileViews.FileGet(fileId);
// LOOP THAT CHECKS IF STATUS IS CHANGED TO "VOIDED"
// THEN NOTIFIES USER IF THERE ARE NON-VOIDED ITEMS IN FILE
foreach (var item in file.FileItems)
{
item.File = file;
// ONLY IF ITEMS EXIST
if (item.ItemCode.Length > 0)
{
// CHECK IF STATUS IS CHANGED TO "VOIDED"
if (newDescription.Equals("Voided"))
{
if (item.ItemStatusID != ItemStatusIDConstants.Voided)
{
result.Success = false;
}
return result.Success;
}
}
}
}