示例#1
0
 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));
 }
示例#2
0
 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));
 }
示例#3
0
 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));
 }
示例#4
0
        /// <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();
        }
示例#5
0
 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));
 }
示例#6
0
        /// <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"));
        }
示例#8
0
        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"));
        }
示例#9
0
        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"));
        }
示例#10
0
        /// <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();
        }
示例#11
0
        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());
        }
示例#12
0
        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());
        }
示例#13
0
        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());
        }
示例#14
0
        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"));
        }