AgGateway.ADAPT.ISOv4Plugin.Loaders.PrescriptionLoader.LoadRateUnits C# (CSharp) Method

LoadRateUnits() private method

private LoadRateUnits ( TreatmentZone treatmentZone, AgGateway.ADAPT.ApplicationDataModel.Prescriptions.RasterGridPrescription prescription ) : void
treatmentZone AgGateway.ADAPT.ISOv4Plugin.Models.TreatmentZone
prescription AgGateway.ADAPT.ApplicationDataModel.Prescriptions.RasterGridPrescription
return void
        private void LoadRateUnits(TreatmentZone treatmentZone, RasterGridPrescription prescription)
        {
            if(prescription.RxProductLookups == null)
                prescription.RxProductLookups = new List<RxProductLookup>();

            var rxRates = new List<RxRate>();
            foreach (var dataVariable in treatmentZone.Variables)
            {
                var product = _taskDocument.Products.FindById(dataVariable.ProductId) ?? _taskDocument.ProductMixes.FindById(dataVariable.ProductId);
                var rxProductLookup = new RxProductLookup
                {
                    ProductId = product == null ? 0 : product.Id.FindIntIsoId(),
                    UnitOfMeasure = dataVariable.IsoUnit.ToAdaptUnit(),
                };
                prescription.RxProductLookups.Add(rxProductLookup);
                var rxRate = new RxRate
                {
                    Rate = dataVariable.Value,
                    RxProductLookupId = rxProductLookup.Id.ReferenceId,
                };
                rxRates.Add(rxRate);
            }
            prescription.Rates = new List<RxRates>{ new RxRates{ RxRate = rxRates }};
        }