private string GetUrl(Navigation entity) { if(entity.Component == SiteModules.Article.ToString()) return Url.Action(entity.Action, entity.Controller, new { Area = "", id = entity.CategoryId }); if (entity.Component == SiteModules.Post.ToString()) return Url.Action(entity.Action, entity.Controller, new { Area = "", id = entity.ContentId }); if (entity.Component == SiteModules.WebContact.ToString()) return Url.Action(entity.Action, entity.Controller, new { Area = "", id = entity.CustomData }); if (entity.Component == SiteModules.Url.ToString()) return entity.ExternalUrl; return Url.Action(entity.Action, entity.Controller, new { Area = ""}); }
public ActionResult Create(FormCollection collection) { try { Navigation navigation = new Navigation() { Name = collection["Name"], Position = collection["Possition"], ContentId = string.IsNullOrEmpty(collection["ContentId"]) ? new Nullable<int>() : int.Parse(collection["ContentId"]), ParentId = string.IsNullOrEmpty(collection["ParentId"]) ? new Nullable<int>() : int.Parse(collection["ParentId"]), Status= EntityStatuses.Actived.ToString(), Component = collection["Component"] }; if(collection["Component"] == SiteModules.Article.ToString()) { if (navigation.ContentId.HasValue) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Category.ToString(); navigation.Area = ""; } } if (collection["Component"] == SiteModules.WebLink.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebLink.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.WebContact.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebContact.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.Url.ToString()) { //navigation.Controller = DBNL.App.Models.Statics.Controllers.WebContact.ToString(); //navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; navigation.ExternalUrl = collection["ExternalUrl"]; } NavigationService.Create(navigation); return RedirectToAction("Index"); } catch { throw; ViewData.Model = new NavigationDataView() { Categories = CustomSelectList.CreateListCategories(true), NavigationPositions = CustomSelectList.CreateMenuPosition(), RootNavigations = CustomSelectList.CreateListNavigations(true) }; return View(); } }
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 DeleteNavigation(Navigation nav) { DBNLDataContext db = new DBNLDataContext(); db.Navigations.DeleteOnSubmit(nav); db.SubmitChanges(); return RedirectToAction("ListNavigations"); }
partial void DeleteNavigation(Navigation instance);
partial void UpdateNavigation(Navigation instance);
partial void InsertNavigation(Navigation instance);
private void detach_Navigations(Navigation entity) { this.SendPropertyChanging(); entity.Content = null; }
private void attach_Navigations(Navigation entity) { this.SendPropertyChanging(); entity.Navigation1 = this; }
private void attach_Navigations(Navigation entity) { this.SendPropertyChanging(); entity.ContentCategory = this; }
public ActionResult Edit(int id, Navigation navigation, FormCollection collection) { try { if (!ModelState.IsValid) { ViewData["ExtraData"] = new NavigationDataView() { Categories = CustomSelectList.CreateListCategories(true, navigation.CategoryId), NavigationPositions = CustomSelectList.CreateMenuPosition(navigation.Position), RootNavigations = CustomSelectList.CreateListNavigations(true, navigation.ParentId), SiteModules = CustomSelectList.CreateModuleList(navigation.Component) }; return View(navigation); } if (collection["Component"] == SiteModules.Post.ToString()) { if (navigation.ContentId.HasValue) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.View.ToString(); navigation.Area = ""; } } if (collection["Component"] == SiteModules.Article.ToString()) { if (navigation.CategoryId.HasValue) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Category.ToString(); navigation.Area = ""; } } if (collection["Component"] == SiteModules.Home.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Home.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.WebLink.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebLink.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.WebContact.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebContact.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } new NavigationService().UpdateMenuItem(navigation); return RedirectToAction("Index"); } catch { ViewData["ExtraData"] = new NavigationDataView() { Categories = CustomSelectList.CreateListCategories(true, navigation.CategoryId), NavigationPositions = CustomSelectList.CreateMenuPosition(navigation.Position), RootNavigations = CustomSelectList.CreateListNavigations(true, navigation.ParentId), SiteModules = CustomSelectList.CreateModuleList(navigation.Component), OrphanArticles = CustomSelectList.CreateListOphanArticles() }; return View(); } }
public ActionResult Create(FormCollection collection, Navigation navigation) { try { navigation.Status= EntityStatuses.Actived.ToString(); if (!ModelState.IsValid) { ViewData["ExtraData"] = new NavigationDataView() { Categories = CustomSelectList.CreateListCategories(true), NavigationPositions = CustomSelectList.CreateMenuPosition(), RootNavigations = CustomSelectList.CreateListNavigations(true), SiteModules = CustomSelectList.CreateModuleList(), OrphanArticles = CustomSelectList.CreateListOphanArticles(), Departments = CustomSelectList.CreateDepartments() }; return View(navigation); } if (collection["Component"] == SiteModules.Post.ToString()) { if (navigation.ContentId.HasValue) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.View.ToString(); navigation.Area = ""; } } if(collection["Component"] == SiteModules.Article.ToString()) { if (navigation.CategoryId.HasValue) { navigation.ContentId = null; navigation.Controller = DBNL.App.Models.Statics.Controllers.Article.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Category.ToString(); navigation.Area = ""; } } if (collection["Component"] == SiteModules.WebLink.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebLink.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.Home.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.Home.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; } if (collection["Component"] == SiteModules.WebContact.ToString()) { navigation.Controller = DBNL.App.Models.Statics.Controllers.WebContact.ToString(); navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); navigation.CustomData = collection["DepartmentId"]; //navigation.Area = ""; } if (collection["Component"] == SiteModules.Url.ToString()) { //navigation.Controller = DBNL.App.Models.Statics.Controllers.WebContact.ToString(); //navigation.Action = DBNL.App.Models.Statics.Actions.Index.ToString(); //navigation.Area = ""; navigation.ExternalUrl = collection["ExternalUrl"]; } new NavigationService().Create(navigation); return RedirectToAction("Index"); } catch { throw; ViewData.Model = new NavigationDataView() { Categories = CustomSelectList.CreateListCategories(true), NavigationPositions = CustomSelectList.CreateMenuPosition(), RootNavigations = CustomSelectList.CreateListNavigations(true), SiteModules = CustomSelectList.CreateModuleList(), OrphanArticles = CustomSelectList.CreateListOphanArticles(), Departments = CustomSelectList.CreateDepartments() }; return View(); } }