private Task <CalcSummaryViewModel> GetSummaryAsync(string fldName)
        {
            CalcSummaryViewModel cvm = new CalcSummaryViewModel();

            cvm.summaryReqd = false;

            var chemicalBalances = _chemicalBalanceMessage.GetChemicalBalances(_ud.GetFieldDetails(fldName), _ud.FarmDetails().FarmRegion.Value, _ud.FarmDetails().Year);
            var msgs             = _chemicalBalanceMessage.DetermineBalanceMessages(_ud.GetFieldDetails(fldName), _ud.FarmDetails().FarmRegion.Value, _ud.FarmDetails().Year);

            foreach (var m in msgs)
            {
                switch (m.Chemical)
                {
                case "CropN":
                    cvm.remNIcon     = m.Icon;
                    cvm.remNIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;

                case "CropP2O5":
                    cvm.remPIcon     = m.Icon;
                    cvm.remPIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;

                case "CropK2O":
                    cvm.remKIcon     = m.Icon;
                    cvm.remKIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;

                case "AgrN":
                    cvm.reqNIcon     = m.Icon;
                    cvm.reqNIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;

                case "AgrP2O5":
                    cvm.reqPIcon     = m.Icon;
                    cvm.reqPIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;

                case "AgrK2O":
                    cvm.reqKIcon     = m.Icon;
                    cvm.reqKIconText = _sd.GetNutrientIcon(m.Icon).Definition;
                    break;
                }
            }

            cvm.reqN        = chemicalBalances.balance_AgrN.ToString();
            cvm.reqP        = chemicalBalances.balance_AgrP2O5.ToString();
            cvm.reqK        = chemicalBalances.balance_AgrK2O.ToString();
            cvm.remN        = chemicalBalances.balance_CropN.ToString();
            cvm.remP        = chemicalBalances.balance_CropP2O5.ToString();
            cvm.remK        = chemicalBalances.balance_CropK2O.ToString();
            cvm.summaryReqd = _chemicalBalanceMessage.DisplayMessages(_ud.GetFieldDetails(fldName));

            return(Task.FromResult(cvm));
        }
Exemplo n.º 2
0
        private Task <CalcMessagesViewModel> GetMessagesAsync(string fldName)
        {
            CalcMessagesViewModel cvm = new CalcMessagesViewModel();

            cvm.messages = null;

            var field = _ud.GetFieldDetails(fldName);

            cvm.messages    = _chemicalBalanceMessage.DetermineBalanceMessages(field, _ud.FarmDetails().FarmRegion.Value, _ud.FarmDetails().Year);
            cvm.displayMsgs = _chemicalBalanceMessage.DisplayMessages(field);

            return(Task.FromResult(cvm));
        }