Ejemplo n.º 1
0
        public ISOCropType ExportCropType(Crop adaptCropType, ISOProductGroup cropTypeProductGroup)
        {
            ISOCropType isoCrop = new ISOCropType(TaskDataMapper.Version);

            //ID
            string id = adaptCropType.Id.FindIsoId() ?? GenerateId();

            isoCrop.CropTypeId = id;
            ExportIDs(adaptCropType.Id, id);
            ExportContextItems(adaptCropType.ContextItems, id, "ADAPT_Context_Items:Crop");

            //Designator
            isoCrop.CropTypeDesignator = adaptCropType.Name;

            //Product Group
            isoCrop.ProductGroupIdRef = cropTypeProductGroup.ProductGroupId;

            //Varieties
            if (DataModel.Catalog.Products != null)
            {
                IEnumerable <Product> varietyProducts = DataModel.Catalog.Products.Where(p => p.ProductType == ProductTypeEnum.Variety);
                if (varietyProducts.Any())
                {
                    IEnumerable <CropVarietyProduct> cropVarieties = varietyProducts.Cast <CropVarietyProduct>().Where(v => v.CropId == adaptCropType.Id.ReferenceId);
                    if (cropVarieties.Any())
                    {
                        CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper);
                        isoCrop.CropVarieties = varietyMapper.ExportCropVarieties(cropVarieties).ToList();
                    }
                }
            }

            return(isoCrop);
        }
Ejemplo n.º 2
0
        public Crop ImportCropType(ISOCropType isoCropType)
        {
            Crop adaptCrop = new Crop();

            //ID
            ImportIDs(adaptCrop.Id, isoCropType.CropTypeId);

            //Description
            adaptCrop.Name = isoCropType.CropTypeDesignator;

            //Varieties
            if (isoCropType.CropVarieties.Any())
            {
                CropVarietyMapper varietyMapper = new CropVarietyMapper(TaskDataMapper);
                varietyMapper.ImportCropVarieties(adaptCrop, isoCropType.CropVarieties);
            }

            return(adaptCrop);
        }