public ActionResult Edit(ProfileData data) { WaterProfile wp = db.WaterProfiles.Where(x => x.UserID == ah.UserID && x.ID == data.WaterProfile.ID).SingleOrDefault(); CalcStats cs = db.CalcStats.Where(x => x.WaterProfileID == wp.ID).SingleOrDefault(); if (cs == null) { cs = new CalcStats(); cs.WaterProfileID = wp.ID; cs.UserID = ah.UserID; cs.ID = -1; db.CalcStats.Add(cs); } List <ModelError> allErrors = new List <ModelError>(); if (ModelState.IsValid) { ProcessWaterProfile(data, wp); ProcessGrainInfo(data, wp); ProcessCalcStats(data, cs); db.SaveChanges(); this.Flash("success", "Successfully modified " + data.WaterProfile.Title + "."); return(RedirectToAction("Index")); } else { allErrors = ModelState.Values.SelectMany(v => v.Errors).ToList(); this.Flash("error", ah.GetFlashErrorString(allErrors)); return(View(data)); } }
private void OnValueChanged(int index) { sourceProfile = targetProfile; targetProfile = profiles[index]; changeTime = Time.time; progressSlider.transform.parent.gameObject.SetActive(true); #if !UNITY_5_0 && !UNITY_5_1 dropdown.interactable = false; #endif }
private void TweenProfiles(WaterProfile source, WaterProfile target, float sunIntensity, float exposure, AmbientGradient ambientGradient, float transitionDuration) { this.sourceAmbient = new AmbientGradient(RenderSettings.ambientGroundColor, RenderSettings.ambientEquatorColor, RenderSettings.ambientSkyColor); this.targetAmbient = ambientGradient; this.transitionDuration = transitionDuration; this.sourceSunIntensity = sun.intensity; this.targetSunIntensity = sunIntensity; this.sourceExposure = RenderSettings.skybox.GetFloat("_Exposure"); this.targetExposure = exposure; this.source = source; this.target = target; water.SetProfiles(new Water.Water.WeightedProfile(source, 1.0f), new Water.Water.WeightedProfile(target, 0.0f)); profileChangeTime = Time.time; }
void Start() { #if !UNITY_5_0 && !UNITY_5_1 dropdown.onValueChanged.AddListener(OnValueChanged); #endif if (water.Profiles == null) { enabled = false; return; } StartCoroutine(CheckWeather()); targetProfile = water.Profiles[0].profile; }
public ActionResult Delete(int id) { WaterProfile waterProfile = db.WaterProfiles.Where(x => x.UserID == ah.UserID && x.ID == id).SingleOrDefault(); if (waterProfile != null) { db.WaterProfiles.Remove(waterProfile); db.SaveChanges(); this.Flash("success", "Deleted " + waterProfile.Title + "."); } else { this.Flash("error", "Water Profile does not exist."); } return(Json(new { Url = new UrlHelper(Request.RequestContext).Action("Index", "WaterProfiles") })); }
private void ProcessGrainInfo(ProfileData data, WaterProfile wp) { foreach (GrainInfo g in data.GrainInfos) { GrainInfo existingG = db.GrainInfos.Find(g.ID); if (existingG != null && g.GrainTypeID == 1) { db.GrainInfos.Remove(existingG); } else if (existingG != null && g.GrainTypeID > 1) { existingG.GrainTypeID = g.GrainTypeID; existingG.Color = g.Color; existingG.MashPH = g.MashPH; existingG.Weight = g.Weight; } else if (existingG == null && g.GrainTypeID > 1) { g.ID = -1; wp.GrainInfos.Add(g); } } }
//Breakout property mapping for editing water profiles #region Mapping private void ProcessWaterProfile(ProfileData data, WaterProfile wp) { wp.AcidulatedMalt = data.WaterProfile.AcidulatedMalt; wp.BakingSoda = data.WaterProfile.BakingSoda; wp.CalciumChloride = data.WaterProfile.CalciumChloride; wp.Chalk = data.WaterProfile.Chalk; wp.EpsomSalt = data.WaterProfile.EpsomSalt; wp.GallonsMashWater = data.WaterProfile.GallonsMashWater; wp.GallonsSpargeWater = data.WaterProfile.GallonsSpargeWater; wp.Gypsum = data.WaterProfile.Gypsum; wp.LacticAcid = data.WaterProfile.LacticAcid; wp.MashWaterDilution = data.WaterProfile.MashWaterDilution; wp.SlakedLime = data.WaterProfile.SlakedLime; wp.SpargeWaterDilution = data.WaterProfile.SpargeWaterDilution; wp.StartingAlkalinity = data.WaterProfile.StartingAlkalinity; wp.StartingCalcium = data.WaterProfile.StartingCalcium; wp.StartingChloride = data.WaterProfile.StartingChloride; wp.StartingMagnesium = data.WaterProfile.StartingMagnesium; wp.StartingSodium = data.WaterProfile.StartingSodium; wp.StartingSulfate = data.WaterProfile.StartingSulfate; wp.Title = data.WaterProfile.Title; wp.ManualPH = data.WaterProfile.ManualPH; }
public void DeleteWaterProfile(WaterProfile waterProfile) { _context.WaterProfiles.Remove(waterProfile); }
public void UpdateWaterProfile(WaterProfile waterProfile) { _context.WaterProfiles.Update(waterProfile); }
public void AddWaterProfile(WaterProfile waterProfile) { _context.WaterProfiles.Add(waterProfile); }