Skip to content

Commit

Permalink
WIP Still need to properly implement conversions
Browse files Browse the repository at this point in the history
  • Loading branch information
dallascrichmond committed Sep 26, 2024
1 parent c60ec85 commit 3dcd19e
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
2 changes: 1 addition & 1 deletion app/Agri.Data/SeedData/FertigationData.json
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,7 @@
{
"Id": 1,
"Name": "g/L",
"ConvFacter": 0.01002,
"ConvFactor": 0.01002,
"StaticDataVersionId": 14
},
{
Expand Down
1 change: 0 additions & 1 deletion app/Agri.Models/Configuration/Fertigation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ public LiquidFertilizerDensity GetLiquidFertilizerDensity( int id, int densityUn
return LiquidFertilizerDensities.Single(density => density.FertilizerId == id && density.DensityUnitId == densityUnitId);
}
public DryFertilizerSolubility GetDryFertilizerSolubility(int id, int solubilityUnitId){
var test = DryFertilizerSolubilities.Single(solubility => solubility.FertilizerId == id && solubility.SolubilityUnitId == solubilityUnitId);
return DryFertilizerSolubilities.Single(solubility => solubility.FertilizerId == id && solubility.SolubilityUnitId == solubilityUnitId);
}

Expand Down
28 changes: 15 additions & 13 deletions app/Server/src/SERVERAPI/Controllers/NutrientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,6 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm)
}
return View(fgvm);
}
// HERE
if (fgvm.buttonPressed == "TankVolumeChange")
{
ModelState.Clear();
Expand All @@ -627,17 +626,21 @@ public IActionResult FertigationDetails(FertigationDetailsViewModel fgvm)
}
return View(fgvm);
}
if (fgvm.buttonPressed == "SolInWaterChange")
if (fgvm.buttonPressed == "SolInWaterUnitChange")
{
ModelState.Clear();
fgvm.buttonPressed = "";
fgvm.btnText = "Calculate";

if (fgvm.selTypOption == "1")
{
FertigationDetailSetup_DefaultSolubility(ref fgvm);
// These are just test conversions. Will need to implement actual conversions!!!
if (fgvm.selSolubilityUnitOption == 3){
var solubility = Convert.ToDecimal(fgvm.solInWater) * 1.2M;
fgvm.solInWater = solubility.ToString("#.##");
}
return View(fgvm);
if (fgvm.selSolubilityUnitOption == 2){
var solubility = Convert.ToDecimal(fgvm.solInWater) * 0.5M;
fgvm.solInWater = solubility.ToString("#.##");
}
return PartialView(fgvm);
}
if (fgvm.buttonPressed == "AmountToDissolveChange")
{
Expand Down Expand Up @@ -925,18 +928,17 @@ private void FertigationDetailSetup_DefaultSolubility(ref FertigationDetailsView
}


if (fgvm.selDensityUnitOption == 0 || fgvm.selFertOption == 0)
if (fgvm.selSolubilityUnitOption == 0 || fgvm.selFertOption == 0)
{
fgvm.density = "";
fgvm.stdDensity = true;
fgvm.solInWater = "";
// fgvm.stdDensity = true;
}

if (!fgvm.manualEntry &&
fgvm.fertilizerType == "dry" &&
fgvm.selFertOption != 0)
fgvm.selFertOption != 0 &&
fgvm.selSolubilityUnitOption != 0)
{
var Test = fgvm.selSolubilityUnitOption;
var Test2 = fgvm.selFertOption;
fgvm.solInWater = _fg.GetDryFertilizerSolubility(Convert.ToInt32(fgvm.selFertOption), Convert.ToInt32(fgvm.selSolubilityUnitOption)).Value.ToString("#.##");

// fgvm.stdDensity = true;
Expand Down
8 changes: 4 additions & 4 deletions app/Server/src/SERVERAPI/Views/Nutrients/Calculate.cshtml
Original file line number Diff line number Diff line change
Expand Up @@ -389,15 +389,15 @@
});
$(document).ready(function () {
$("body").on("change", "#ddlTankVolume", function () {
$('#buttonPressed').val("TankVolumeChange");
$("body").on("change", "#ddlSolubilityUnits", function () {
$('#buttonPressed').val("SolInWaterUnitChange");
$("#modForm").submit();
})
});
$(document).ready(function () {
$("body").on("change", "#ddlSolInWater", function () {
$('#buttonPressed').val("SolInWaterChange");
$("body").on("change", "#ddlTankVolume", function () {
$('#buttonPressed').val("TankVolumeChange");
$("#modForm").submit();
})
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@
<div class="form-group col-sm-2" style="margin-left:0px;padding-left:0px; width:100px">
<div style="display:table; width:100%">
<div style="display:table-row">
<label for="ddlSolubility" style="text-align: center; display: block;">Units</label>
<select class="form-control" asp-for="selSolubilityUnitOption" asp-items="@(new SelectList(Model.solubilityUnitOptions,"Id","Value"))" id="ddlSolubility"></select>
<label for="ddlSolubilityUnits" style="text-align: center; display: block;">Units</label>
<select class="form-control" asp-for="selSolubilityUnitOption" asp-items="@(new SelectList(Model.solubilityUnitOptions,"Id","Value"))" id="ddlSolubilityUnits"></select>
<span asp-validation-for="selSolubilityUnitOption" class="text-danger"></span>
</div>
</div>
Expand Down Expand Up @@ -425,6 +425,7 @@
@Html.HiddenFor(x => x.tankVolume)
@Html.HiddenFor(x => x.solInWater)
@Html.HiddenFor(x => x.amountToDissolve)
@Html.HiddenFor(x => x.selSolubilityUnitOption)

@Html.HiddenFor(x => x.fertigationTime)
@Html.HiddenFor(x => x.totProductVolPerFert)
Expand Down

0 comments on commit 3dcd19e

Please sign in to comment.