private List <System.Web.Mvc.SelectListItem> LoadSoils(long?soilId = null, Horizon horizon = null) { SoilConfiguration sc = new SoilConfiguration(); List <Soil> soils = sc.GetAllSoils(); List <System.Web.Mvc.SelectListItem> result = new List <SelectListItem>(); foreach (var item in soils) { bool isSelected = false; if (horizon != null && soilId.HasValue) { isSelected = (horizon.SoilId == soilId); } SelectListItem sl = new SelectListItem() { Value = item.SoilId.ToString(), Text = item.ShortName, Selected = isSelected }; result.Add(sl); } return(result); }
public ActionResult DeleteConfirmed(long id) { SoilConfiguration sc = new SoilConfiguration(); Soil soil = db.Soils.Find(id); sc.Disable(soil); db.SaveChanges(); return(Redirect("/Soils")); }
/// <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(); }