public ActionResult Create(Pages pages)
        {
            pages.CreatedDate = DateTime.Now;
            if (db.Pages.Count() != 0)
            {
                pages.SortIndex = db.Pages.OrderByDescending(p => p.SortIndex).FirstOrDefault().SortIndex + 1;
            }
            else
            {
                pages.SortIndex = 1;
            }
            pages.FK_User = (int)Membership.GetUser().ProviderUserKey;

            if (pages.FK_Parent != null)
            {
                pages.indentlevel = db.Pages.Where(p => p.Id == pages.FK_Parent).FirstOrDefault().indentlevel + 1;
                pages.SortIndex = db.Pages.Where(p => p.Id == pages.FK_Parent).FirstOrDefault().SortIndex + 1;
            }
            else
            {
                pages.indentlevel = 0;
            }

            pages.PageTemplate = (int)Enum.Parse(typeof(DA.Helpers.Templates), pages.PageTemplate.ToString());
            db.Pages.Add(pages);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
        public ActionResult Edit(Pages pages)
        {
            if (ModelState.IsValid)
            {
            //                pages.CreatedDate = (DateTime)pages.CreatedDate;
                pages.FK_User = (int)Membership.GetUser().ProviderUserKey;
                db.Entry(pages).State = EntityState.Modified;
                pages.PageTemplate = (int)Enum.Parse(typeof(DA.Helpers.Templates), pages.PageTemplate.ToString());

                if (pages.FK_Parent != null)
                {
                    pages.indentlevel = db.Pages.Where(p => p.Id == pages.FK_Parent).FirstOrDefault().indentlevel + 1;
                    pages.SortIndex = db.Pages.Where(p => p.Id == pages.FK_Parent).FirstOrDefault().SortIndex;
                }
                else
                {
                    pages.indentlevel = 0;
                }

                db.SaveChanges();
                return RedirectToAction("Index");
            }
            ViewBag.FK_Parent = new SelectList(db.Pages, "Id", "Name", pages.FK_Parent);
            ViewBag.FK_Status = new SelectList(db.Status, "Id", "Name", pages.FK_Status);
            return View(pages);
        }