Exemplo n.º 1
0
 public ActionResult AddContent(Content content)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Contents.InsertOnSubmit(content);
     db.SubmitChanges();
     return RedirectToAction("ListContents");
 }
Exemplo n.º 2
0
        private static void DoMigration(int oldid, int newid)
        {
            DBNLDataContext db = new DBNLDataContext();

            XDocument doc = XDocument.Load("articles.xml");
            foreach (var ele in doc.Root.Elements("table"))
            {
                //.Where(p => p.Element("column").Attribute("cid").Value == oldid.ToString())
                var cid = ele.Elements("column").Where(a => a.Attribute("name").Value == "cid").Select(a => a.Value).FirstOrDefault();
                if (cid != oldid.ToString()) continue;

                var name =  ele.Elements("column").Where(a => a.Attribute("name").Value == "name_vn").Select(a => a.Value).FirstOrDefault();
                var content_vn = ele.Elements("column").Where(a => a.Attribute("name").Value == "content_vn").Select(a => a.Value).FirstOrDefault();
                var img = ele.Elements("column").Where(a => a.Attribute("name").Value == "img").Select(a => a.Value).FirstOrDefault();
                var dated = ele.Elements("column").Where(a => a.Attribute("name").Value == "dated").Select(a => a.Value).FirstOrDefault();
                var ids = ele.Elements("column").Where(a => a.Attribute("name").Value == "id").Select(a => a.Value).FirstOrDefault();

                int id = int.Parse(ids);
                //if(id <847) continue;
                DateTime d = DateTime.ParseExact(dated, "yyyy-MM-dd", null);
                Content c = new Content()
                {
                    Title = name,
                    Content1 = HttpUtility.HtmlDecode(content_vn),
                    Picture = img,
                    Status = "Actived",
                    CreatedDate = d,
                    CategoryId = newid,

                };

                c.UpdatedDate = c.CreatedDate;
                c.UniqueKey = c.Title.ToUrlKey();
                c.Content1 = c.Content1.Replace("/fckFiles/image/", "/Resources/Galleries/");
                c.Description = c.Content1.TrimmedWord(100);
                Console.WriteLine(c.Title);
                c.Picture = c.Picture.Substring(c.Picture.LastIndexOf("/") + 1);
                db.Contents.InsertOnSubmit(c);
                db.SubmitChanges();

            }
        }
Exemplo n.º 3
0
 public ActionResult EditContent(int id, Content content)
 {
     DBNLDataContext db = new DBNLDataContext();
     Content updContent = db.Contents.Where(p => p.ContentId == id).SingleOrDefault();
     updContent.ContentCategory = content.ContentCategory;
     updContent.Count = content.Count;
     updContent.CreatedDate = content.CreatedDate;
     updContent.Status = content.Status;
     updContent.Title = content.Title;
     updContent.UpdatedDate = content.UpdatedDate;
     updContent.IsFeatured = content.IsFeatured;
     db.SubmitChanges();
     return RedirectToAction("ListContents");
 }
Exemplo n.º 4
0
 partial void DeleteContent(Content instance);
Exemplo n.º 5
0
 partial void UpdateContent(Content instance);
Exemplo n.º 6
0
 partial void InsertContent(Content instance);
Exemplo n.º 7
0
		private void detach_Contents(Content entity)
		{
			this.SendPropertyChanging();
			entity.ContentCategory = null;
		}
Exemplo n.º 8
0
		private void attach_Contents(Content entity)
		{
			this.SendPropertyChanging();
			entity.ContentCategory = this;
		}