Exemplo n.º 1
0
 public Menu()
 {
     ParentId = string.Empty;
     Id = DateTime.Now.ToString("yyddmmHHss");
     Page = new ContentPage();
 }
 public ActionResult AddPage(PageModel adPageModel)
 {
     if (!User.Identity.IsAuthenticated)
         return RedirectToAction("LogOn", "Account");
     if (ModelState.IsValid)
     {
         var scope = ObjectScopeProvider1.GetNewObjectScope();
         var contentPage = new ContentPage { Name = adPageModel.PageTitle, Content = adPageModel.Content, Id = DateTime.Now.Ticks.ToString() };
         scope.Transaction.Begin();
         scope.Add(contentPage);
         scope.Transaction.Commit();
         try
         {
             using (var connection = new SqlConnection("Data Source=208.91.198.196;Initial Catalog=admin_hopestrack;Persist Security Info=True;User ID=hopestrack;Password=password@123"))
             {
                 connection.Open();
                 string qry = "update content_page set [<_content>k___backing_field] = '" + adPageModel.Content + "' where [<_id>k___backing_field]='" + contentPage.Id + "'";
                 var command = new SqlCommand(qry, connection);
                 command.ExecuteNonQuery();
                 connection.Close();
             }
         }
         catch (Exception)
         {
             LoadPages();
             return View("Pages");
         }
         LoadPages();
         return View("Pages");
     }
     return View(adPageModel);
 }