Example #1
0
        private void SavePage(VPage model)
        {
            Page page;
            var  now = DateTime.UtcNow;

            if (model.Id == 0)
            {
                page          = new Page();
                page.Created  = now;
                page.PageType = model.PageType;
                _ctx.Pages.AddObject(page);
            }
            else
            {
                page = _ctx.Pages.First(t => t.Id == model.Id);
            }

            page.Title = model.NTitle ?? "";
            //page.PageTitle = model.PageTitle ?? "";
            page.Slug      = model.Slug ?? "";
            page.Announce  = model.Announce ?? "";
            page.Text      = model.Text ?? "";
            page.HomePage  = model.IsHot;
            page.Updated   = now;
            page.Published = model.Published;
            _ctx.SaveChanges();

            model.Id = page.Id;
        }
Example #2
0
        protected VPage ConvertToVPage(Page model)
        {
            var vPage = new VPage
            {
                Announce  = model.Announce,
                Updated   = model.Updated,
                Published = model.Published,
                Id        = model.Id,
                NTitle    = model.Title,
                Text      = model.Text,
                PageType  = model.PageType,
            };

            return(vPage);
        }
Example #3
0
        public ActionResult EditSave(VPage model, string returnPage)
        {
            var saveAndAdd = Request["SaveAndAdd"];

            //AuthorizeCurrentRole(SystemRoles.Admin);
            if (ModelState.IsValid)
            {
                SavePage(model);
                if (!String.IsNullOrWhiteSpace(saveAndAdd))
                {
                    return(RedirectToAction("edit", new { id = "", pageType = model.PageType }));
                }
                return(RedirectToAction("ShowById", new { id = model.Id }));
            }

            return(View("Edit", model));
        }
Example #4
0
        public ActionResult Edit(int?id, string pageType)
        {
            var model = new VPage();

            if (id == null)
            {
                ViewBag.Title += " - Add";
                model.PageType = pageType;
            }
            else
            {
                ViewBag.Title += " - Edit";
                var page = _ctx.Pages.First(n => n.Id == id);
                model.NTitle = page.Title;
                //model.PageTitle = page.PageTitle;
                model.Slug      = page.Slug;
                model.Announce  = page.Announce;
                model.Text      = page.Text;
                model.IsHot     = page.HomePage;
                model.Published = page.Published;
                model.Id        = page.Id;
                if (page.PageType == PageType.Contacts)
                {
                    model.ReturnUrl = "/contacts";
                }
                else if (page.PageType == PageType.News)
                {
                    model.ReturnUrl = "/news";
                }
                else
                {
                    model.ReturnUrl = "/";
                }
            }

            return(View("Edit", model));
        }