public ActionResult AddBanner(Banner banner) { DBNLDataContext db = new DBNLDataContext(); db.Banners.InsertOnSubmit(banner); db.SubmitChanges(); return RedirectToAction("ListBanners"); }
public ActionResult AddContact(Contact contact) { DBNLDataContext db = new DBNLDataContext(); db.Contacts.InsertOnSubmit(contact); db.SubmitChanges(); return RedirectToAction("ListContacts"); }
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 static void DoReplace() { DBNLDataContext db = new DBNLDataContext(); foreach (var item in db.Contents) { item.Description = item.Description.ReplaceHtmlEntities(); db.SubmitChanges(); } }
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(); } }
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 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 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, 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 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 DeleteRole(Role role) { DBNLDataContext db = new DBNLDataContext(); db.Roles.DeleteOnSubmit(role); db.SubmitChanges(); return RedirectToAction("ListRoles"); }
public ActionResult DeleteNavigation(Navigation nav) { DBNLDataContext db = new DBNLDataContext(); db.Navigations.DeleteOnSubmit(nav); db.SubmitChanges(); return RedirectToAction("ListNavigations"); }
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 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 DeletePoll(Poll poll) { DBNLDataContext db = new DBNLDataContext(); db.Polls.DeleteOnSubmit(poll); db.SubmitChanges(); return RedirectToAction("ListPolls"); }
public ActionResult DeleteSupporter(Supporter supporter) { DBNLDataContext db = new DBNLDataContext(); db.Supporters.DeleteOnSubmit(supporter); db.SubmitChanges(); return RedirectToAction("ListSupporters"); }
public ActionResult DeleteContent(Content content) { DBNLDataContext db = new DBNLDataContext(); db.Contents.DeleteOnSubmit(content); db.SubmitChanges(); return RedirectToAction("ListContents"); }
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 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 DeletePollQuestion(PollQuestion question) { DBNLDataContext db = new DBNLDataContext(); db.PollQuestions.DeleteOnSubmit(question); db.SubmitChanges(); return RedirectToAction("ListPollQuestions"); }
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 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"); }
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 AddUser(User user) { DBNLDataContext db = new DBNLDataContext(); db.Users.InsertOnSubmit(user); db.SubmitChanges(); return RedirectToAction("ListUsers"); }