示例#1
0
        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");
        }
示例#2
0
 partial void DeleteNavigationLink(NavigationLink instance);
示例#3
0
 partial void UpdateNavigationLink(NavigationLink instance);
示例#4
0
 partial void InsertNavigationLink(NavigationLink instance);
示例#5
0
		private void detach_NavigationLinks(NavigationLink entity)
		{
			this.SendPropertyChanging();
			entity.WebPage = null;
		}
示例#6
0
		private void attach_NavigationLinks(NavigationLink entity)
		{
			this.SendPropertyChanging();
			entity.Section = this;
		}