Skip to content

Commit

Permalink
Fix: Persist edits to dry fertigation data (#700)
Browse files Browse the repository at this point in the history
- Ensure changes to dry fertigation data are saved
- Resolve issue where edits were not being retained
  • Loading branch information
PaulGarewal authored Oct 16, 2024
1 parent 1304e42 commit 12774b2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 2 deletions.
8 changes: 8 additions & 0 deletions app/Agri.Models/Farm/NutrientFertilizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ public class NutrientFertilizer
public bool isFertigation { get; set; }
public decimal injectionRate { get; set; }
public int injectionRateUnitId { get; set; }
public decimal tankVolume { get; set; }
public int tankVolumeUnitId { get; set; }
public decimal solInWater { get; set; }
public decimal amountToDissolve { get; set; }
public int dissolveUnitId { get; set; }
public decimal nutrientConcentrationN { get; set; }
public decimal nutrientConcentrationP205 { get; set; }
public decimal nutrientConcentrationK2O { get; set; }
public string groupID { get; set; }
}
}
29 changes: 27 additions & 2 deletions app/Server/src/SERVERAPI/Controllers/NutrientsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ public IActionResult ManureDetails(string fldName, int? id)

public IActionResult FertigationDetails(string fldName, int? id, string? groupID)
{
var thign = ModelState.IsValid;
var fgvm = new FertigationDetailsViewModel()
{
fieldName = fldName,
Expand Down Expand Up @@ -296,6 +295,15 @@ public IActionResult FertigationDetails(string fldName, int? id, string? groupID
fgvm.selFertSchedOption = nf.applMethodId.ToString();
fgvm.injectionRate = nf.injectionRate.ToString("#.##");
fgvm.selInjectionRateUnitOption = nf.injectionRateUnitId.ToString();
fgvm.tankVolume = nf.tankVolume.ToString("#.##");
fgvm.selTankVolumeUnitOption = nf.tankVolumeUnitId;
fgvm.solInWater = nf.solInWater.ToString("#.##");
fgvm.selSolubilityUnitOption = nf.solInWaterUnitId;
fgvm.amountToDissolve = nf.amountToDissolve.ToString("#.##");
fgvm.selDissolveUnitOption = nf.dissolveUnitId;
fgvm.nutrientConcentrationN = nf.nutrientConcentrationN.ToString("#.##");
fgvm.nutrientConcentrationP205 = nf.nutrientConcentrationP205.ToString("#.##");
fgvm.nutrientConcentrationK2O = nf.nutrientConcentrationK2O.ToString("#.##");
if (!ft.Custom && ft.DryLiquid == "liquid")
{
if (fgvm.density != _fg.GetLiquidFertilizerDensity(nf.fertilizerId, nf.liquidDensityUnitId).Value.ToString("#.##"))
Expand Down Expand Up @@ -480,7 +488,6 @@ private List<SelectListItem> GetOptionsList<T>(List<T> selectOption) where T: Se

private void FertigationDetailsSetup(ref FertigationDetailsViewModel fgvm)
{
//here we will have to add the solid units dropdown
fgvm.typOptions = GetOptionsList(_fg.FertilizerTypes);
fgvm.fertOptions = GetFertigationFertilizers(fgvm.selTypOption);
fgvm.productRateUnitOptions = GetOptionsList(_fg.ProductRateUnits);
Expand Down Expand Up @@ -1137,6 +1144,15 @@ private List<int> FertigationInsert(FertigationDetailsViewModel fgvm)
isFertigation = true,
injectionRate = Convert.ToDecimal(fgvm.injectionRate),
injectionRateUnitId = Convert.ToInt32(fgvm.selInjectionRateUnitOption),
tankVolume = Convert.ToDecimal(fgvm.tankVolume),
tankVolumeUnitId = Convert.ToInt32(fgvm.selTankVolumeUnitOption),
solInWater = Convert.ToDecimal(fgvm.solInWater),
solInWaterUnitId = Convert.ToInt32(fgvm.selSolubilityUnitOption),
amountToDissolve = Convert.ToDecimal(fgvm.amountToDissolve),
dissolveUnitId = Convert.ToInt32(fgvm.amountToDissolveUnits),
nutrientConcentrationN = Convert.ToDecimal(fgvm.nutrientConcentrationN),
nutrientConcentrationP205 = Convert.ToDecimal(fgvm.nutrientConcentrationP205),
nutrientConcentrationK2O = Convert.ToDecimal(fgvm.nutrientConcentrationK2O),
groupID = groupID
};

Expand Down Expand Up @@ -1215,6 +1231,15 @@ private void FertigationUpdate(FertigationDetailsViewModel fgvm)
groupID = fgvm.groupID,
injectionRate = Convert.ToDecimal(fgvm.injectionRate),
injectionRateUnitId = Convert.ToInt32(fgvm.selInjectionRateUnitOption),
tankVolume = Convert.ToDecimal(fgvm.tankVolume),
tankVolumeUnitId = Convert.ToInt32(fgvm.selTankVolumeUnitOption),
solInWater = Convert.ToDecimal(fgvm.solInWater),
solInWaterUnitId = Convert.ToInt32(fgvm.selSolubilityUnitOption),
amountToDissolve = Convert.ToDecimal(fgvm.amountToDissolve),
dissolveUnitId = Convert.ToInt32(fgvm.amountToDissolveUnits),
nutrientConcentrationN = Convert.ToDecimal(fgvm.nutrientConcentrationN),
nutrientConcentrationP205 = Convert.ToDecimal(fgvm.nutrientConcentrationP205),
nutrientConcentrationK2O = Convert.ToDecimal(fgvm.nutrientConcentrationK2O),
isFertigation = true
};

Expand Down

0 comments on commit 12774b2

Please sign in to comment.