Example #1
0
        private void add_Click(object sender, System.EventArgs e)
        {
            if (_repo.FindConfigOption(optionKey.Text) != null)
            {
                MessageBox.Show("Такая настройка уже есть.");
                return;
            }

            var newConfigOption = new ConfigOption { Key = optionKey.Text, Value = optionValue.Text};
            _repo.AddConfigOption(newConfigOption);

            RefreshView();
        }
        public ConfigOption AddConfigOption(ConfigOption co)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                context.Config.Add(co);
                context.SaveChanges();

                return co;
            }
        }
        public void UpdateConfigOption(ConfigOption co)
        {
            using (var context = new ScheduleContext(ConnectionString))
            {
                var curCO = context.Config.FirstOrDefault(opt => opt.ConfigOptionId == co.ConfigOptionId);

                curCO.Key = co.Key;
                curCO.Value = co.Value;

                context.SaveChanges();
            }
        }