public static bool UpdateTextContent(TextContent textContent, bool addIfNotExist = true)
 {
     using (var db = CreateDataContext())
     {
         try
         {
             TextContent contentInDB = db.TextContents.FirstOrDefault(s => s.ControlName == textContent.ControlName);
             if (contentInDB == null)
             {
                 if (!addIfNotExist) return true;
                 db.TextContents.Add(textContent);
             }
             else
             {
                 contentInDB.Content = textContent.Content;
                 contentInDB.Title = textContent.Title;
             }
             db.SaveChanges();
             return true;
         }
         catch (Exception ex)
         {
             //todo: log
             return false;
         }
     }
 }
 protected void btnUpdate_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(btnSave.CommandArgument))
     {
         TextContent tc = new TextContent
                             {
                                 Content = txtContent.Content,
                                 Title = txtTitle.Text,
                                 ControlName = btnSave.CommandArgument
                             };
         if (TextContentManager.UpdateTextContent(tc))
         {
             CacheManager.RefreshTextContent(tc.ControlName);
             Response.Redirect(string.Format("~/{0}.aspx", tc.ControlName));
         }
         else
         {
             DisplayErrorMessage();
         }
     }
 }