public ActionResult Edit([Bind(Include = "RegionId,Name,PositionId")] Region region) { if (ModelState.IsValid) { db.Entry(region).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.PositionId = new SelectList(db.Positions, "PositionId", "Name", region.PositionId); return(View(region)); }
public ActionResult Edit([Bind(Include = "CropId,Name,RegionId,SpecieId,Density,MaxEvapotranspirationToIrrigate,MinEvapotranspirationToIrrigate")] Crop crop) { if (ModelState.IsValid) { db.Entry(crop).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RegionId = new SelectList(db.Regions, "RegionId", "Name", crop.RegionId); ViewBag.SpecieId = new SelectList(db.Species, "SpecieId", "Name", crop.SpecieId); return(View(crop)); }
public ActionResult Edit([Bind(Include = "UserFarmId,UserId,FarmId,Name,StartDate")] UserFarm userFarm) { if (ModelState.IsValid) { db.Entry(userFarm).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.FarmId = new SelectList(db.Farms, "FarmId", "Name", userFarm.FarmId); ViewBag.UserId = new SelectList(db.Users, "UserId", "Name", userFarm.UserId); return(View(userFarm)); }
/// <summary> /// Logical elimination /// </summary> /// <param name="pSoil"></param> public void Disable(Soil pSoil) { pSoil.Enabled = false; List <Horizon> listHorizon = pSoil.HorizonList; foreach (Horizon h in listHorizon) { h.Enabled = false; } db.Entry(pSoil).State = EntityState.Modified; //db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "PhenologicalStageAdjustmentId,Name,CropId,DateOfChange,StageId,PhenologicalStageId,Observation")] PhenologicalStageAdjustment phenologicalStageAdjustment) { if (ModelState.IsValid) { db.Entry(phenologicalStageAdjustment).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CropId = new SelectList(db.Crops, "CropId", "Name", phenologicalStageAdjustment.CropId); ViewBag.PhenologicalStageId = new SelectList(db.PhenologicalStages, "PhenologicalStageId", "PhenologicalStageId", phenologicalStageAdjustment.PhenologicalStageId); ViewBag.StageId = new SelectList(db.Stages, "StageId", "Name", phenologicalStageAdjustment.StageId); return(View(phenologicalStageAdjustment)); }
/// <summary> /// Logical or fisical elimination /// </summary> /// <param name="pHorizon"></param> public void Disable(IrrigationUnit pIrrigationUnit) { List <CropIrrigationWeather> lReturn = null; if (pIrrigationUnit != null) { lReturn = db.CropIrrigationWeathers .Where(ciw => ciw.IrrigationUnitId == pIrrigationUnit.IrrigationUnitId).ToList(); } //fisical delete if (lReturn.Count == 0) { db.Entry(pIrrigationUnit).State = EntityState.Deleted; } else { pIrrigationUnit.Enabled = false; db.Entry(pIrrigationUnit).State = EntityState.Modified; } // db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "PhenologicalStageId,SpecieId, StageId, MinDegree,MaxDegree,RootDepth,HydricBalanceDepth,Coefficient,DegreesDaysInterval")] PhenologicalStageViewModel phenologicalStageViewModel) { if (ModelState.IsValid) { PhenologicalStage phenologicalStage = db.PhenologicalStages.Find(phenologicalStageViewModel.PhenologicalStageId); if (phenologicalStage == null) { return(HttpNotFound()); } phenologicalStage.SpecieId = phenologicalStageViewModel.SpecieId; phenologicalStage.StageId = phenologicalStageViewModel.StageId; phenologicalStage.MinDegree = phenologicalStageViewModel.MinDegree; phenologicalStage.MaxDegree = phenologicalStageViewModel.MaxDegree; phenologicalStage.RootDepth = phenologicalStageViewModel.RootDepth; phenologicalStage.HydricBalanceDepth = phenologicalStageViewModel.HydricBalanceDepth; phenologicalStage.Coefficient = phenologicalStageViewModel.Coefficient; phenologicalStage.DegreesDaysInterval = phenologicalStageViewModel.DegreesDaysInterval; db.Entry(phenologicalStage).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/PhenologicalStages")); }
public ActionResult Edit([Bind(Include = "StageId,Name,ShortName,Description,Order")] Stage stage) { if (ModelState.IsValid) { Stage updatedstage = db.Stages.Find(stage.StageId); if (updatedstage == null) { return(HttpNotFound()); } updatedstage.Name = stage.Name; updatedstage.ShortName = stage.ShortName; updatedstage.Description = stage.Description; updatedstage.Order = stage.Order; db.Entry(updatedstage).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/Stages")); }
public ActionResult Edit([Bind(Include = "SpecieCycleId,Name,Duration,RegionId")] SpecieCycleViewModel scvm) { if (ModelState.IsValid) { SpecieCycle updatedSpecieCycle = db.SpecieCycles.Find(scvm.SpecieCycleId); if (updatedSpecieCycle == null) { return(HttpNotFound()); } updatedSpecieCycle.Name = scvm.Name; updatedSpecieCycle.Duration = scvm.Duration; updatedSpecieCycle.RegionId = scvm.RegionId; db.Entry(updatedSpecieCycle).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/SpecieCycles")); }
/// <summary> /// Logical elimination /// </summary> /// <param name="pFarm"></param> /// <returns></returns> public void Disable(Farm pFarm) { SoilConfiguration sc = new SoilConfiguration(); IrrigationUnitConfiguration iuc = new IrrigationUnitConfiguration(); List <Soil> listSoil = pFarm.SoilList; List <IrrigationUnit> listIrrigationUnit = pFarm.IrrigationUnitList; foreach (Soil soil in listSoil) { sc.Disable(soil); } foreach (IrrigationUnit irrigationUnit in listIrrigationUnit) { iuc.Disable(irrigationUnit); } pFarm.IsActive = false; db.Entry(pFarm).State = EntityState.Modified; //db.SaveChanges(); }
public ActionResult Edit([Bind(Include = "SoilId,ShortName,Description,TestDate,DepthLimit,Latitude,Longitude")] SoilViewModel soilViewModel) { if (ModelState.IsValid) { Soil updatedSoil = db.Soils.Find(soilViewModel.SoilId); if (updatedSoil == null) { return(HttpNotFound()); } updatedSoil.ShortName = soilViewModel.ShortName; updatedSoil.Description = soilViewModel.Description; updatedSoil.TestDate = soilViewModel.TestDate; updatedSoil.DepthLimit = soilViewModel.DepthLimit; updatedSoil.Position.Latitude = soilViewModel.Latitude; updatedSoil.Position.Longitude = soilViewModel.Longitude; db.Entry(updatedSoil).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/Soils")); //var lSoilList = db.Soils.Include(b => b.Farm); //return View("~/Views/Agriculture/Soils/Index.cshtml", lSoilList.ToList()); }
public ActionResult Edit([Bind(Include = "IrrigationUnitId,ShortName,IrrigationType,IrrigationEfficiency,PredeterminatedIrrigationQuantity, Surface,FarmId, BombId, Latitude, Longitude, Show, Width,Length")] SprinklerViewModel sprinkleViewModel) { if (ModelState.IsValid) { Sprinkler lSprinkler = db.Sprinklers.Find(sprinkleViewModel.IrrigationUnitId); long positionId = GetPositionId(sprinkleViewModel.Latitude, sprinkleViewModel.Longitude); Position lPosition = new Position(); //Not exist position if (positionId == 0) { lPosition.Latitude = sprinkleViewModel.Latitude; lPosition.Longitude = sprinkleViewModel.Longitude; lPosition.Name = sprinkleViewModel.Farm.Name + " - " + sprinkleViewModel.Name + " - Unidad de riego"; lSprinkler.Position = lPosition; } else { lSprinkler.PositionId = positionId; } lSprinkler.ShortName = sprinkleViewModel.ShortName; lSprinkler.BombId = sprinkleViewModel.BombId; lSprinkler.FarmId = sprinkleViewModel.FarmId; lSprinkler.IrrigationEfficiency = sprinkleViewModel.IrrigationEfficiency; lSprinkler.PredeterminatedIrrigationQuantity = sprinkleViewModel.PredeterminatedIrrigationQuantity; lSprinkler.Surface = sprinkleViewModel.Surface; lSprinkler.Show = sprinkleViewModel.Show; lSprinkler.Width = sprinkleViewModel.Width; lSprinkler.Length = sprinkleViewModel.Length; // lSprinkler.IrrigationType = Utils.IrrigationUnitType.Sprinkler; db.Entry(lSprinkler).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/IrrigationUnit")); //var lList = db.IrrigationUnits.Include(f => f.Farm); //return View("~/Views/Irrigation/IrrigationUnit/Index.cshtml", lList.ToList()); }
public ActionResult Edit([Bind(Include = "IrrigationUnitId,ShortName,IrrigationType,IrrigationEfficiency,PredeterminatedIrrigationQuantity, Surface,FarmId, BombId, Latitude, Longitude, Show, Radius")] PivotViewModel pivotViewModel) { if (ModelState.IsValid) { Pivot lPivot = db.Pivots.Find(pivotViewModel.IrrigationUnitId); long positionId = GetPositionId(pivotViewModel.Latitude, pivotViewModel.Longitude); Position lPosition = new Position(); //Not exist position if (positionId == 0) { lPosition.Latitude = pivotViewModel.Latitude; lPosition.Longitude = pivotViewModel.Longitude; lPosition.Name = pivotViewModel.Farm.Name + " - " + pivotViewModel.Name + " - Unidad de riego"; lPivot.Position = lPosition; } else { lPivot.PositionId = positionId; } lPivot.ShortName = pivotViewModel.ShortName; lPivot.BombId = pivotViewModel.BombId; lPivot.FarmId = pivotViewModel.FarmId; lPivot.IrrigationEfficiency = pivotViewModel.IrrigationEfficiency; lPivot.PredeterminatedIrrigationQuantity = pivotViewModel.PredeterminatedIrrigationQuantity; lPivot.Surface = pivotViewModel.Surface; lPivot.Show = pivotViewModel.Show; lPivot.Radius = pivotViewModel.Radius; // lPivot.IrrigationType = Utils.IrrigationUnitType.Sprinkler; db.Entry(lPivot).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/IrrigationUnit")); //var lList = db.IrrigationUnits.Include(f => f.Farm); //return View("~/Views/Irrigation/IrrigationUnit/Index.cshtml", lList.ToList()); }
public ActionResult Edit([Bind(Include = "SpecieId,ShortName,SpecieCycleId,BaseTemperature,StressTemperature, RegionId, ")] SpecieViewModel svm) { if (ModelState.IsValid) { SpecieCycle specieCycle = db.SpecieCycles.Find(svm.SpecieCycleId); Specie updatedSpecie = db.Species.Find(svm.SpecieId); if (updatedSpecie == null) { return(HttpNotFound()); } updatedSpecie.Name = svm.ShortName + " " + specieCycle.Name; updatedSpecie.ShortName = svm.ShortName; updatedSpecie.BaseTemperature = svm.BaseTemperature; updatedSpecie.StressTemperature = svm.StressTemperature; updatedSpecie.SpecieCycleId = svm.SpecieCycleId; updatedSpecie.RegionId = svm.RegionId; updatedSpecie.SpecieType = svm.SpecieType; db.Entry(updatedSpecie).State = EntityState.Modified; db.SaveChanges(); } return(Redirect("/Species")); }