public ActionResult Save(bool autoRefresh) { try { var option = _repository.Options.FirstOrDefault(x => x.Key == "AutoRefresh"); if (option == null) { option = new Option() { Key = "AutoRefresh" }; } option.Value = autoRefresh.ToString(); _repository.SaveOption(option); TempData["Message"] = "Options saved"; } catch (Exception ex) { TempData["Error"] = "Error saving options: " + ex.Message.ToString(); } return RedirectToAction("Index", new { feed = "options" }); }
public void SaveOption(Option option) { if (option.OptionID == 0) { _optionTable.InsertOnSubmit(option); } _context.SubmitChanges(); }
public Option GetOption(string key) { var option = _repository.Options.FirstOrDefault(x => x.Key == key); if (option == null) { option = new Option() { Key = key, Value = string.Empty }; } return option; }