public void Update(WaterLevel waterLevel) { db.Entry(waterLevel).State = EntityState.Modified; db.Configuration.ValidateOnSaveEnabled = false; Save(); db.Configuration.ValidateOnSaveEnabled = true; }
public ActionResult Edit(WaterLevel lvl) { try { objBs.Update(lvl); TempData["Msg"] = "Acceptable water level updated successfully"; return RedirectToAction("Index"); } catch (Exception e) { TempData["Msg"] = "Update failed" + e.Message; return RedirectToAction("Index"); } }
public void Insert(WaterLevel waterLevel) { db.WaterLevels.Add(waterLevel); Save(); }
public void Insert(WaterLevel level) { objDb.Insert(level); }
public void UpdateOrCreate(List<JSONModel> models) { List<WaterLevel> fromDb = GetAll().ToList(); foreach (JSONModel item in models) { List<WaterLevel> comapreResult = fromDb.Where(db => db.County == item.County && db.WaterBody == item.WaterBody && db.Name == item.Name.text).ToList(); if (!comapreResult.Any()) { WaterLevel lvl = new WaterLevel(); lvl.Name = item.Name.text; lvl.County = item.County; if (item.WaterLevel == null || item.WaterLevel == "") { lvl.WaterLevel1 = "Default (0.000 m)"; lvl.AWaterLevel = "Default (0.000 m)"; } else { lvl.AWaterLevel = item.WaterLevel; lvl.WaterLevel1 = item.WaterLevel; } lvl.URL = item.Name.href; lvl.WaterBody = item.WaterBody; Insert(lvl); } else { WaterLevel lvl = fromDb.First(l => l.County == item.County && l.WaterBody == item.WaterBody && l.Name == item.Name.text); lvl.WaterLevel1 = item.WaterLevel; if (lvl.WaterLevel1 == null || lvl.WaterLevel1 == "") { lvl.WaterLevel1 = "Default (0.000 m)"; lvl.AWaterLevel = "Default (0.000 m)"; } Update(lvl); } } }
public void Update(WaterLevel level) { objDb.Update(level); }