コード例 #1
0
        public void Update(WaterLevel waterLevel)
        {
            db.Entry(waterLevel).State = EntityState.Modified;
            db.Configuration.ValidateOnSaveEnabled = false;

            Save();

            db.Configuration.ValidateOnSaveEnabled = true;
        }
コード例 #2
0
        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");
            }
        }
コード例 #3
0
 public void Insert(WaterLevel waterLevel)
 {
     db.WaterLevels.Add(waterLevel);
     Save();
 }
コード例 #4
0
 public void Insert(WaterLevel level)
 {
     objDb.Insert(level);
 }
コード例 #5
0
        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);
                }
            }
        }
コード例 #6
0
 public void Update(WaterLevel level)
 {
     objDb.Update(level);
 }