Exemple #1
0
        private IEnumerable <RequestedResourceViewModel> GetRequestedResources()
        {
            List <RequestedResourceViewModel> resources = new List <RequestedResourceViewModel>();

            List <OperationResource> dataSource = GetOperationCustomData <List <OperationResource> >("Einsatzmittel", null);

            if (dataSource != null)
            {
                foreach (OperationResource resource in dataSource)
                {
                    // Check if the filter matches
                    var vehicle = _configuration.FindMatchingResource(resource.FullName);
                    if (vehicle == null)
                    {
                        continue;
                    }

                    // Construct new requested resource.
                    RequestedResourceViewModel rvm = new RequestedResourceViewModel();
                    // Find out the vehicle type or specification (if any).
                    rvm.ResourceType = GetVehicleType(resource);
                    // Allocate the requested equipment (if any).
                    if (resource.RequestedEquipment != null && resource.RequestedEquipment.Count > 0)
                    {
                        rvm.ResourceName = string.Join("\n", resource.RequestedEquipment);
                    }
                    else
                    {
                        // If there is no requested equipment, and the resource type wasn't found, set the vehicle name.
                        if (!rvm.HasResourceType)
                        {
                            rvm.ResourceName = vehicle.Name;
                        }
                    }

                    resources.Add(rvm);
                }
            }

            return(resources.OrderBy(r => r.ResourceName));
        }
        private IEnumerable<RequestedResourceViewModel> GetRequestedResources()
        {
            List<RequestedResourceViewModel> resources = new List<RequestedResourceViewModel>();

            if (_operation != null && _operation.Resources != null)
            {
                foreach (OperationResource resource in _operation.Resources)
                {
                    // Check if the filter matches
                    var vehicle = _configuration.FindMatchingResource(resource.FullName);
                    if (vehicle == null)
                    {
                        continue;
                    }

                    // Construct new requested resource.
                    RequestedResourceViewModel rvm = new RequestedResourceViewModel();
                    // Find out the vehicle type or specification (if any).
                    rvm.ResourceType = GetVehicleType(resource);
                    // Allocate the requested equipment (if any).
                    if (resource.RequestedEquipment != null && resource.RequestedEquipment.Count > 0)
                    {
                        rvm.ResourceName = string.Join("\n", resource.RequestedEquipment);
                    }
                    else
                    {
                        // If there is no requested equipment, and the resource type wasn't found, set the vehicle name.
                        if (!rvm.HasResourceType)
                        {
                            rvm.ResourceName = vehicle.Name;
                        }
                    }

                    resources.Add(rvm);
                }
            }

            return resources.OrderBy(r => r.ResourceName);
        }