Exemple #1
0
        public ActionResult DeleteConfirmed(long id)
        {
            //Sprinkler lSprinkler = db.Sprinklers.Find(id);
            //lSprinkler.Show = false;
            //db.Entry(lSprinkler).State = EntityState.Modified;
            //db.SaveChanges();

            IrrigationUnitConfiguration fc = new IrrigationUnitConfiguration();
            IrrigationUnit irrigationUnit  = db.IrrigationUnits.Find(id);

            fc.Disable(irrigationUnit);
            db.SaveChanges();

            return(Redirect("/IrrigationUnit"));
            //var lList = db.IrrigationUnits.Include(f => f.Farm);
            //return View("~/Views/Irrigation/IrrigationUnit/Index.cshtml", lList.ToList());
        }
Exemple #2
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();
        }