public IActionResult SoilTest(SoilTestViewModel fvm) { fvm.tstOptions = new List <SelectListItem>(); fvm.tstOptions = _sd.GetSoilTestMethodsDll().ToList(); if (fvm.buttonPressed == "MethodChange") { ModelState.Clear(); FarmDetails fd = _ud.FarmDetails(); fd.TestingMethod = fvm.selTstOption == "select" ? string.Empty : fvm.selTstOption; _ud.UpdateFarmDetails(fd); fvm.testSelected = string.IsNullOrEmpty(fd.TestingMethod) ? false : true; List <Field> fl = _ud.GetFields(); //update fields with convert STP and STK _ud.UpdateSTPSTK(fl); //update the Nutrient calculations with the new/changed soil test data var updatedFields = _chemicalBalanceMessage.RecalcCropsSoilTestMessagesByFarm(_ud.GetFields(), _ud.FarmDetails().FarmRegion.Value); foreach (var field in updatedFields) { foreach (var crop in field.Crops) { _ud.UpdateFieldCrop(field.FieldName, crop); } } RedirectToAction("SoilTest", "Soil"); } return(View(fvm)); }
public IActionResult SoilTest(SoilTestViewModel fvm) { fvm.tstOptions = new List <SelectListItem>(); fvm.tstOptions = _sd.GetSoilTestMethodsDll().ToList(); if (fvm.buttonPressed == "MethodChange") { ModelState.Clear(); FarmDetails fd = _ud.FarmDetails(); fd.testingMethod = fvm.selTstOption == "select" ? string.Empty : fvm.selTstOption; _ud.UpdateFarmDetails(fd); fvm.testSelected = string.IsNullOrEmpty(fd.testingMethod) ? false : true; List <Field> fl = _ud.GetFields(); //update fields with convert STP and STK _ud.UpdateSTPSTK(fl); //update the Nutrient calculations with the new/changed soil test data Utility.ChemicalBalanceMessage cbm = new Utility.ChemicalBalanceMessage(_ud, _sd); cbm.RecalcCropsSoilTestMessagesByFarm(); RedirectToAction("SoilTest", "Soil"); } return(View(fvm)); }
public IActionResult SoilTest() { SoilTestViewModel fvm = new SoilTestViewModel(); FarmDetails fd = _ud.FarmDetails(); fvm.selTstOption = fd.testingMethod; if (!string.IsNullOrEmpty(fd.testingMethod)) { fvm.testSelected = true; } fvm.tstOptions = new List <Models.StaticData.SelectListItem>(); fvm.tstOptions = _sd.GetSoilTestMethodsDll().ToList(); List <Field> fl = _ud.GetFields(); fvm.fldsFnd = (fl.Count() > 0) ? true : false; fvm.url = _sd.GetExternalLink("soiltestexplanation"); fvm.warningMsg = _sd.GetUserPrompt("soiltestwarning"); return(View(fvm)); }