public async Task <IActionResult> Edit(int id, [Bind("ID,Key,Type,Value,Description")] Setting setting) { if (id != setting.ID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(setting); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!SettingExists(setting.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(setting)); }
public void Save(New t) { if (t.newsid > 0) { dbContext.Update <New>(t); } else { dbContext.Insert <New>(t); } }
public virtual async Task UpdateAsync(TEntity obj) { try { _context.Entry(obj).State = EntityState.Modified; _context.Update(obj); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!_context.Set <TEntity>().Any()) { return; } else { throw; } } }
public async Task <IActionResult> Edit(int id, [Bind("ID,Pin,Type,CurrentValue")] GPIO gPIO) { if (id != gPIO.ID) { return(NotFound()); } if (ModelState.IsValid) { try { if (gPIO.Type == "In") { gPIO.CurrentValue = int.Parse(System.IO.File.ReadAllText($"./GPIO/GPIO-{gPIO.Pin}.txt")); } else { System.IO.File.WriteAllText($"./GPIO/GPIO-{gPIO.Pin}.txt", gPIO.CurrentValue.ToString()); } _context.Update(gPIO); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!GPIOExists(gPIO.ID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(gPIO)); }