Esempio n. 1
0
        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");
        }
Esempio n. 2
0
 partial void DeleteSection(Section instance);
Esempio n. 3
0
 partial void UpdateSection(Section instance);
Esempio n. 4
0
 partial void InsertSection(Section instance);
Esempio n. 5
0
		private void detach_Sections(Section entity)
		{
			this.SendPropertyChanging();
			entity.Tab = null;
		}
Esempio n. 6
0
		private void attach_Sections(Section entity)
		{
			this.SendPropertyChanging();
			entity.Tab = this;
		}