Пример #1
0
        private Task <SoilTestsViewModel> GetSoilTestAsync()
        {
            SoilTestsViewModel svm = new SoilTestsViewModel();

            Utility.SoilTestConversions stc = new SoilTestConversions(_ud, _sd);

            svm.missingTests = false;

            FarmDetails fd = _ud.FarmDetails();

            svm.testingMethod = fd.testingMethod;

            svm.tests = new List <DisplaySoilTest>();

            List <Field> flds = _ud.GetFields();

            foreach (var m in flds)
            {
                DisplaySoilTest dc = new DisplaySoilTest();
                dc.fldName = m.fieldName;
                if (m.soilTest != null)
                {
                    dc.sampleDate  = m.soilTest.sampleDate.ToString("MMM-yyyy");
                    dc.dispNO3H    = m.soilTest.valNO3H.ToString();
                    dc.dispP       = m.soilTest.ValP.ToString();
                    dc.dispK       = m.soilTest.valK.ToString();
                    dc.dispPH      = m.soilTest.valPH.ToString();
                    dc.dispPRating = _sd.SoilTestRating("phosphorous", stc.GetConvertedSTP(m.soilTest));
                    dc.dispKRating = _sd.SoilTestRating("potassium", stc.GetConvertedSTK(m.soilTest));
                }
                else
                {
                    svm.missingTests = true;
                }
                svm.tests.Add(dc);
            }

            return(Task.FromResult(svm));
        }