public string UpdateOptionInfo() { string op1Name = request.Params["opt1Name"]; string op1Required = request.Params["opt1Required"]; string op1Enabled = request.Params["opt1Enabled"]; string op2Name = request.Params["opt2Name"]; string op2Required = request.Params["opt2Required"]; string op2Enabled = request.Params["opt2Enabled"]; using (DB db = new DB(DBHelper.GetConnectionString(_currentClient))) { OptionInfo opt1 = (from o in db.OptionInfoes where o.Number == 1 && o.Client == _currentClient select o).FirstOrDefault(); OptionInfo opt2 = (from o in db.OptionInfoes where o.Number == 2 && o.Client == _currentClient select o).FirstOrDefault(); if (opt1 == null) { opt1 = new OptionInfo() { Client = _currentClient, Number = 1 }; db.AddToOptionInfoes(opt1); } if (opt2 == null) { opt2 = new OptionInfo() { Client = _currentClient, Number = 2 }; db.AddToOptionInfoes(opt2); } opt1.IsRequired = Convert.ToBoolean(op1Required); opt1.Enabled = Convert.ToBoolean(op1Enabled); opt1.Name = op1Name; opt2.IsRequired = Convert.ToBoolean(op2Required); opt2.Enabled = Convert.ToBoolean(op2Enabled); opt2.Name = op2Name; return (db.SaveChanges() > 0).ToString(); } }