public void DoTaskElement(TaskElement element) { Debug.WriteLine("Current taskelement:"); Debug.WriteLine("ID: " + element.Id + "\n Name:" + element.Name + "\n Description: " + element.Description); if (element.TypeId != null) { Models.Type type = typeController.GetTypeAsync(element.TypeId).Result; Debug.WriteLine("Required type: " + type.Name + "\n" + type.Description); Debug.WriteLine("+++++++++++++"); List <ContainerPartContent> cpcList = containerPartContentController.GetContainerPartContentAsync(type.Id).Result; if (cpcList != null) { var cpc = cpcList.FirstOrDefault(); ContainerPart containerPart = containerPartController.GetContainerPartAsync(cpc.ContainerPartId).Result; Debug.WriteLine("There is/are " + cpc.Amount + " in the " + containerPart.Name + " containerpart."); } else { throw new Exception("There isn't containerpart which contains the given type."); } } }