public ActionResult AddContentCategory(ContentCategory contentCate)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.ContentCategories.InsertOnSubmit(contentCate);
     db.SubmitChanges();
     return RedirectToAction("ListContentCategories");
 }
 public ActionResult AddContentRelation(ContentRelation contentRelation)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.ContentRelations.InsertOnSubmit(contentRelation);
     db.SubmitChanges();
     return RedirectToAction("ListContentRelations");
 }
 public ActionResult AddContact(Contact contact)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Contacts.InsertOnSubmit(contact);
     db.SubmitChanges();
     return RedirectToAction("ListContacts");
 }
 public ActionResult AddBanner(Banner banner)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Banners.InsertOnSubmit(banner);
     db.SubmitChanges();
     return RedirectToAction("ListBanners");
 }
Esempio n. 5
0
        public static void DoReplace()
        {
            DBNLDataContext db = new DBNLDataContext();
            foreach (var item in db.Contents)
            {

                item.Description = item.Description.ReplaceHtmlEntities();
                db.SubmitChanges();
            }
        }
Esempio n. 6
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();

            }
        }
Esempio n. 7
0
        private static void FixDB()
        {
            DBNLDataContext db = new DBNLDataContext();

            var items = from p in db.Contents
                        join p2 in db.Contents on p.Title equals p2.Title
                        where p.ContentId != p2.ContentId
                        select p;

            foreach (var item in items)
            {
                var query = from i in db.Contents
                            where i.Title == item.Title && i.ContentId != item.ContentId
                            select i;
                foreach (var k in query)
                {
                    Console.WriteLine(k.ContentId.ToString() +"\t"+k.Title);
                    db.Contents.DeleteOnSubmit(k);
                    db.SubmitChanges();
                }

            }
        }
 public ActionResult ListNavigations()
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.Navigations;
     return View();
 }
 public ActionResult ListPollQuestions()
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.PollQuestions;
     return View();
 }
 public ActionResult EditLink(int id, Link link)
 {
     DBNLDataContext db = new DBNLDataContext();
     Link updLink = db.Links.Where(p => p.Id == id).SingleOrDefault();
     updLink.CreatedDate = link.CreatedDate;
     updLink.Title = link.Title;
     updLink.UpdatedDate = link.UpdatedDate;
     updLink.Url = link.Url;
     db.SubmitChanges();
     return RedirectToAction("ListLinks");
 }
 public ActionResult ListContentRelations()
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.ContentRelations;
     return View();
 }
 public ActionResult AddLink(Link link)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.Links.InsertOnSubmit(link);
     db.SubmitChanges();
     return RedirectToAction("ListLinks");
 }
 public ActionResult DeleteUserInRole(UserInRole userInRole)
 {
     DBNLDataContext db = new DBNLDataContext();
     db.UserInRoles.DeleteOnSubmit(userInRole);
     db.SubmitChanges();
     return RedirectToAction("ListUserInRoles");
 }
 public ActionResult EditSupporter(int id)
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.Supporters.Where(p => p.Id == id).SingleOrDefault();
     return View();
 }
 public ActionResult EditContact(int id, Contact contact)
 {
     DBNLDataContext db = new DBNLDataContext();
     Contact updContact = db.Contacts.Where(p => p.Id == id).SingleOrDefault();
     updContact.Name = contact.Name;
     updContact.Email = contact.Email;
     updContact.Status = contact.Status;
     db.SubmitChanges();
     return RedirectToAction("ListContacts");
 }
 public ActionResult EditPollQuestion(int id, PollQuestion question)
 {
     DBNLDataContext db = new DBNLDataContext();
     PollQuestion updPollQuestion = db.PollQuestions.Where(p => p.Id == id).SingleOrDefault();
     updPollQuestion.CreatedDate = question.CreatedDate;
     updPollQuestion.PollId = question.PollId;
     updPollQuestion.Status = question.Status;
     updPollQuestion.UpdatedDate = updPollQuestion.UpdatedDate;
     updPollQuestion.Question = question.Question;
     updPollQuestion.Responses = question.Responses;
     db.SubmitChanges();
     return RedirectToAction("ListPollQuestions");
 }
 public ActionResult EditRole(int id, Role role)
 {
     DBNLDataContext db = new DBNLDataContext();
     Role updRole = db.Roles.Where(p => p.Id == id).SingleOrDefault();
     updRole.ComponentPermission = role.ComponentPermission;
     updRole.ContentPermission = role.ContentPermission;
     updRole.RoleName = role.RoleName;
     db.SubmitChanges();
     return RedirectToAction("ListRoles");
 }
 public ActionResult EditPollQuestion(int id)
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.PollQuestions.Where(p => p.Id == id).SingleOrDefault();
     return View();
 }
 public ActionResult EditPoll(int id, Poll poll)
 {
     DBNLDataContext db = new DBNLDataContext();
     Poll updPoll = db.Polls.Where(p => p.Id == id).SingleOrDefault();
     updPoll.PollName = poll.PollName;
     updPoll.Status = poll.Status;
     db.SubmitChanges();
     return RedirectToAction("ListPolls");
 }
 public ActionResult EditNavigation(int id, Navigation nav)
 {
     DBNLDataContext db = new DBNLDataContext();
     Navigation updNavigation = db.Navigations.Where(p => p.Id == id).SingleOrDefault();
     updNavigation.Component = nav.Component;
     updNavigation.ContentCategory = nav.ContentCategory;
     updNavigation.CategoryId = nav.CategoryId;
     updNavigation.DisplayOrder = nav.DisplayOrder;
     updNavigation.ExternalUrl = nav.ExternalUrl;
     updNavigation.Image = nav.Image;
     updNavigation.Name = nav.Name;
     updNavigation.ParentId = nav.ParentId;
     updNavigation.Position = nav.Position;
     updNavigation.RelativeUrl = nav.RelativeUrl;
     updNavigation.Status = nav.Status;
     updNavigation.Navigations = nav.Navigations;
     db.SubmitChanges();
     return RedirectToAction("ListNavigations");
 }
 public ActionResult ListUsers()
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.Users;
     return View();
 }
 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");
 }
 public ActionResult ViewContentCategoryDetails(int id)
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.ContentCategories.Where(p => p.ID == id).SingleOrDefault();
     return View();
 }
 public ActionResult EditUser(int id, User user)
 {
     DBNLDataContext db = new DBNLDataContext();
     User updUser = db.Users.Where(p => p.Id == id).SingleOrDefault();
     updUser.CreatedDate = user.CreatedDate;
     updUser.Name = user.Name;
     updUser.Password = user.Password;
     updUser.Status = user.Status;
     updUser.UpdatedDate = user.UpdatedDate;
     updUser.Username = user.Username;
     db.SubmitChanges();
     return RedirectToAction("ListUsers");
 }
 public ActionResult ViewUserDetails(int id)
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.Users.Where(p => p.Id == id).SingleOrDefault();
     return View();
 }
 public ActionResult EditContent(int id)
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.Contents.Where(p => p.ContentId == id).SingleOrDefault();
     return View();
 }
 public ActionResult EditBanner(int id, Banner banner)
 {
     DBNLDataContext db = new DBNLDataContext();
     Banner updBanner = db.Banners.Where(p => p.Id == id).SingleOrDefault();
     updBanner.BannerImage = banner.BannerImage;
     updBanner.BannerPosition = banner.BannerPosition;
     updBanner.CreatedDate = banner.CreatedDate;
     updBanner.Name = banner.Name;
     updBanner.Status = banner.Status;
     updBanner.UpdatedDate = banner.UpdatedDate;
     updBanner.Url = banner.Url;
     db.SubmitChanges();
     return RedirectToAction("ListBanners");
 }
 public ActionResult ListContentCategories()
 {
     DBNLDataContext db = new DBNLDataContext();
     ViewData.Model = db.ContentCategories;
     return View();
 }
 public ActionResult EditSupporter(int id, Supporter supporter)
 {
     DBNLDataContext db = new DBNLDataContext();
     Supporter sp = db.Supporters.Where(p => p.Id == id).SingleOrDefault();
     sp.Name = supporter.Name;
     sp.NickName = supporter.NickName;
     sp.Status = supporter.Status;
     sp.Type = supporter.Type;
     db.SubmitChanges();
     return RedirectToAction("ListSupporter");
 }
 public ActionResult EditContentCategory(int id, ContentCategory contentCate)
 {
     DBNLDataContext db = new DBNLDataContext();
     ContentCategory updContentCate = db.ContentCategories.Where(p => p.ID == id).SingleOrDefault();
     updContentCate.CategoryName = contentCate.CategoryName;
     updContentCate.Key = contentCate.Key;
     updContentCate.ParentCategoryId = contentCate.ParentCategoryId;
     db.SubmitChanges();
     return RedirectToAction("ListContentCategories");
 }