public ActionResult Add(Section s, string tabId) { if (ModelState.IsValid) { if (s.Title.ToLower().Equals("faq")) { ModelState.AddModelError("", "faq is protected name for FAQ pages under Tabs and cannot be used. Please try using different name."); } else { DBDataContext db = Utils.DB.GetContext(); s.Position = db.Sections.Where(x => x.TabID == Convert.ToInt32(tabId)).Count() + 1; Tab t = db.Tabs.SingleOrDefault(x => x.ID == Convert.ToInt32(tabId)); if (t != null) { t.Sections.Add(s); try { db.SubmitChanges(); return RedirectToAction("Index", "Section", new { controller = "Section", tab = tabId }); } catch (Exception ex) { ErrorHandler.Report.Exception(ex, "Section/Add"); ModelState.AddModelError("", "An unknown error occurred. Please try again in few minutes."); } } else { ModelState.AddModelError("", "Tab does not exist in the database"); } } } ViewData["Title"] = "Add Section"; ViewData["Action"] = "Add"; ViewData["TabID"] = tabId; return View("Manage"); }
partial void DeleteSection(Section instance);
partial void UpdateSection(Section instance);
partial void InsertSection(Section instance);
private void detach_Sections(Section entity) { this.SendPropertyChanging(); entity.Tab = null; }
private void attach_Sections(Section entity) { this.SendPropertyChanging(); entity.Tab = this; }