Esempio n. 1
0
            public animalDataTypeAnimalStock Bind()
            {
                if (AverageQuantity == 0 &&
                    DeclarationDayQuantity == 0 &&
                    SummeringPreviousYearDuration == 0 &&
                    SummeringPreviousYearQuantity == 0)
                {
                    return(null);
                }

                var target = new animalDataTypeAnimalStock
                {
                    animalCategory = AnimalTypeCode.FormatCodeToItemEnum <animalCategoryType>(),
                    surveyFarmId   = FarmKtidb,
                    creationDate   = LatestChangeDate,
                };
                var selfReportedData = new selfReportedDataType
                {
                    averageQuantity        = AverageQuantity.ToString(),
                    declarationDayQuantity = DeclarationDayQuantity.ToString(),
                    keepingTypeSpecified   = AnimalTypeNeedsStablingMethod,
                    summeringDuration      = SummeringPreviousYearDuration.ToString(),
                    summeringQuantity      = SummeringPreviousYearQuantity.ToString(),
                };

                if (selfReportedData.keepingTypeSpecified)
                {
                    if ((AnimalTypeNeedsPigsStablingMethod && PigsStablingMethodCode == default(int)) ||
                        (AnimalTypeNeedsPoultryStablingMethod && PoultryStablingMethodCode == default(int)))
                    {
                        Log.Warning("Farm {0} needs {1} keeping type but has none", FarmKtidb,
                                    AnimalTypeNeedsPigsStablingMethod ? "pigs" :
                                    AnimalTypeNeedsPoultryStablingMethod ? "poultry" :
                                    "no"
                                    );
                    }

                    var keepingCode = AnimalTypeNeedsPigsStablingMethod ? PigsStablingMethodCode : PoultryStablingMethodCode;

                    selfReportedData.keepingType = keepingCode.FormatCodeToItemEnum(animalKeepingType.Item0, "0");
                }
                target.Items = new List <object>(new[] { selfReportedData });
                return(target);
            }
Esempio n. 2
0
            public animalDataTypeAnimalStock Bind()
            {
                var target = new animalDataTypeAnimalStock
                {
                    animalCategory = AnimalTypeCode.CheckAnimalCodes().FormatCodeToItemEnum <animalCategoryType>(),
                    surveyFarmId   = FarmKtidb,
                    creationDate   = LatestChangeDate,
                };
                var selfReportedData = new selfReportedDataType
                {
                    averageQuantity        = DeclarationDayQuantity.ToString(),
                    declarationDayQuantity = DeclarationDayQuantity.ToString(),
                    keepingTypeSpecified   = false,
                    summeringDuration      = "0",
                    summeringQuantity      = SummeringPreviousYearQuantity.ToString()
                };

                target.Items = new List <object>(new[] { selfReportedData });
                return(target);
            }