public Error Save(Error error) { _context.Add(error); _context.SaveChanges(); return(error); }
public Environment Save(Environment environment) { _context.Add(environment); _context.SaveChanges(); return(environment); }
public User Save(User user) { _context.Add(user); _context.SaveChanges(); return(user); }
public Level Save(Level level) { _context.Add(level); _context.SaveChanges(); return(level); }
public async Task <IActionResult> Create([Bind("ID,Name,Postcode")] Apiary apiary) { if (ModelState.IsValid) { _context.Add(apiary); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(apiary)); }
public async Task <IActionResult> Create([Bind("ID,Name")] Beehive beehive) { if (ModelState.IsValid) { _context.Add(beehive); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(beehive)); }
public ResultObj SaveData(MonitorContext monitorContext) { _isSaving = true; while (_isPinging) { Console.WriteLine("Waiting for Ping to stop in MonitorPingService.Save"); Thread.Sleep(1000); } ResultObj result = new ResultObj(); result.Success = false; Console.WriteLine("Starting MonitorPingService.Save"); try { int maxDataSetID = 0; try { maxDataSetID = monitorContext.MonitorPingInfos.Max(m => m.DataSetID); } catch { } maxDataSetID++; foreach (MonitorPingInfo monitorPingInfo in _monitorPingInfos) { monitorPingInfo.ID = 0; monitorPingInfo.DataSetID = maxDataSetID; monitorContext.Add(monitorPingInfo); } monitorContext.SaveChanges(); foreach (MonitorPingInfo monitorPingInfo in _monitorPingInfos) { foreach (PingInfo pingInfo in monitorPingInfo.pingInfos) { pingInfo.MonitorPingInfoID = monitorPingInfo.ID; } } foreach (MonitorPingInfo monitorPingInfo in _monitorPingInfos) { foreach (PingInfo pingInfo in monitorPingInfo.pingInfos) { pingInfo.ID = 0; monitorContext.Add(pingInfo); } } monitorContext.SaveChanges(); _netStatsService.stop(); List <NetStat> netStatsData = new List <NetStat>(_netStatsService.NetStatData); foreach (NetStat netStat in netStatsData) { //netStat.ID = 0; netStat.DataSetID = maxDataSetID; monitorContext.Add(netStat); } monitorContext.SaveChanges(); result.Message = "DB Update Success in MonitorPinService.SaveData."; result.Success = true; } catch (Exception e) { result.Message = "DB Update Failed in MonitorPinService.SaveData. Error was : " + e.Message; } finally { // Make sure the reset of the MonitorPingService Object is run just before the next schedule. init(false); _netStatsService.resetData(); _isSaving = false; Console.WriteLine("Finished MonitorPingService.Save"); } return(result); }