public ActionResult Add(NavigationLink l, string webPageId, string tabId, string sectionId) { if (ModelState.IsValid) { DBDataContext db = Utils.DB.GetContext(); l.Position = db.NavigationLinks.Where(x=>x.SectionID == Convert.ToInt32(sectionId)).Count() + 1; Section s = db.Sections.SingleOrDefault(x => x.ID == Convert.ToInt32(sectionId)); if (s != null) { s.NavigationLinks.Add(l); l.WebPageID = Convert.ToInt32(webPageId); try { db.SubmitChanges(); return RedirectToAction("Index", "Link", new { controller = "Link", tab = tabId, section = sectionId }); } catch (Exception ex) { ErrorHandler.Report.Exception(ex, "Links/Add"); ModelState.AddModelError("", "An unknown error occurred. Please try again in few minutes."); } } else { ModelState.AddModelError("", "Section does not exist in the database"); } } ViewData["Title"] = "Add Link"; ViewData["Action"] = "Add"; ViewData["TabID"] = tabId; ViewData["SectionID"] = sectionId; return View("Manage"); }
partial void DeleteNavigationLink(NavigationLink instance);
partial void UpdateNavigationLink(NavigationLink instance);
partial void InsertNavigationLink(NavigationLink instance);
private void detach_NavigationLinks(NavigationLink entity) { this.SendPropertyChanging(); entity.WebPage = null; }
private void attach_NavigationLinks(NavigationLink entity) { this.SendPropertyChanging(); entity.Section = this; }