示例#1
0
 private void AssignCustomer(XmlNode inputNode, Farm farm)
 {
     var customerId = inputNode.GetXmlNodeValue("@I");
     if (string.IsNullOrEmpty(customerId) == false)
     {
         var customer = _taskDocument.Customers.FindById(customerId);
         if (customer != null)
             farm.GrowerId = customer.Id.ReferenceId;
     }
 }
        private FRM MapFarm(Farm farm, Dictionary<int, string> keyToIsoId, int farmIndex)
        {
            var isoFarm = new FRM
            {
                B = farm.Description,
            };
            isoFarm.A = isoFarm.GetIsoId(farmIndex);
            if (farm.GrowerId != null)
                isoFarm.I = keyToIsoId[farm.GrowerId.Value];

            keyToIsoId.Add(farm.Id.ReferenceId, isoFarm.A);
            return isoFarm;
        }
示例#3
0
        public void GivenTaskWhenMapThenFarmIdIsMapped()
        {
            _task.D = "FRM4";
            var farm = new Farm();
            farm.Id.UniqueIds.Add(new UniqueId
            {
                Source = UniqueIdMapper.IsoSource,
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Id = _task.D,
            });
            _dataModel.Catalog.Farms.Add(farm);

            var result = MapSingle();
            Assert.AreEqual(farm.Id.ReferenceId, result.FarmIds.First());
        }
示例#4
0
        private void LoadContactInfo(XmlNode inputNode, Farm farm)
        {
            var contactInfo = new ContactInfo();

            contactInfo.AddressLine1 = inputNode.GetXmlNodeValue("@C");
            contactInfo.PoBoxNumber = inputNode.GetXmlNodeValue("@D");
            contactInfo.PostalCode = inputNode.GetXmlNodeValue("@E");
            contactInfo.City = inputNode.GetXmlNodeValue("@F");
            contactInfo.StateOrProvince = inputNode.GetXmlNodeValue("@G");
            contactInfo.Country = inputNode.GetXmlNodeValue("@H");

            farm.ContactInfo = contactInfo;

            _taskDocument.Contacts.Add(contactInfo);
        }
示例#5
0
        private string WriteFarm(XmlWriter writer, Farm farm)
        {
            var farmId = farm.Id.FindIsoId() ?? GenerateId();
            TaskWriter.Ids.Add(farmId, farm.Id);

            writer.WriteStartElement(XmlPrefix);
            writer.WriteAttributeString("A", farmId);
            writer.WriteAttributeString("B", farm.Description);

            WriteContactInfo(writer, farm.ContactInfo);
            WriteCustomerReference(writer, farm.GrowerId);

            writer.WriteEndElement();

            return farmId;
        }
示例#6
0
        public void GIvenLoggedDataWithFarmIdWhenMapThenDisMapped()
        {
            var farm = new Farm();
            farm.Id.UniqueIds.Add(new UniqueId
            {
                CiTypeEnum = CompoundIdentifierTypeEnum.String,
                Id = "FRM2",
                Source = UniqueIdMapper.IsoSource,
            });
            _catalog.Farms = new List<Farm> { farm };

            _loggedData.FarmId = farm.Id.ReferenceId;

            var result = MapSingle();

            Assert.AreEqual("FRM2", result.D);
        }
示例#7
0
        private Farm LoadFarm(XmlNode inputNode, out string farmId)
        {
            var farm = new Farm();

            // Required fields. Do not proceed if they are missing
            farmId = inputNode.GetXmlNodeValue("@A");
            farm.Description = inputNode.GetXmlNodeValue("@B");
            if (farmId == null || farm.Description == null)
                return null;

            farm.Id.UniqueIds.Add(ImportHelper.CreateUniqueId(farmId));

            // Optional fields
            LoadContactInfo(inputNode, farm);

            AssignCustomer(inputNode, farm);

            _taskDocument.LoadLinkedIds(farmId, farm.Id);
            return farm;
        }