Posted on 26/04/2017 11:20:20
It through an 'object cannot be null' exception, when I debug. In the 'FindBrokerItem' method I can see it finds items but still fails, when it returns.
Extender code, where it fails in 'List<Item> i = itemhandler.FindBrokerItem(id, "Medarbejder", ImportedMedarbejderID)':
FindItemHandler itemhandler = new FindItemHandler();
List<Item> employees = new List<Item>();
foreach (string id in brokerIdList)
{
List<Item> i = new List<Item>();
i = itemhandler.FindBrokerItem(id, "Medarbejder", ImportedMedarbejderID);
if (i.Count > 0)
{
employees.Add(i[0]);
}
}
--------------------------------------------
FindBrokerItem method:
public List<Item> FindBrokerItem(string brokerId, string itemType, int pageID)
{
List<Item> itemList = new List<Item>();
var paragraphs = Paragraph.GetParagraphsByPageID(pageID).Where(x => x.ShowParagraph);
foreach (Paragraph p in paragraphs)
{
var items = ItemManager.Storage.GetByParagraphId(itemType, p.ID).Where(x => x["BrokerID"].ToString() == brokerId);
foreach (var item in items)
{
itemList.Add(item);
break;
}
if (itemList.Any())
{
break;
}
}
return itemList;
}