Exemplo n.º 1
0
        public async Task <IActionResult> Create(PagesEditViewModel model)
        {
            Regex checkStub = new Regex(@"^[\w\-]*$");

            if (!checkStub.IsMatch(model.Page.Stub))
            {
                ModelState.AddModelError("Page.Stub", "Invalid stub, only letters, numbers, hypens and underscores are allowed");
            }
            if (ModelState.IsValid)
            {
                try
                {
                    await _pageService.AddPageAsync(model.Page);

                    AlertSuccess = $"Page '{model.Page.Title}' created";
                    return(RedirectToAction("Index"));
                }
                catch (GraException gex)
                {
                    AlertInfo = gex.Message;
                }
            }
            PageTitle = "Create Page";
            return(View(model));
        }
Exemplo n.º 2
0
        public ViewResult Create()
        {
            var pagesEditViewModel = new PagesEditViewModel();
            pagesEditViewModel.Init(_iconsService.Value.All);

            return View(nameof(PagesController.Edit), pagesEditViewModel);
        }
Exemplo n.º 3
0
        public void UpdateManagerPages(PagesEditViewModel model)
        {
            var query = from p in m_contentContext.Pages
                        where p.Id == model.Id
                        select p;
            var item = query.FirstOrDefault();

            Mapper.Map(model, item);
            m_contentContext.SaveChanges();
        }
Exemplo n.º 4
0
        public void InsertManagerPages(PagesEditViewModel model)
        {
            var item = Mapper.Map <Pages>(model);

            var qryNr = m_contentContext.Pages.Select(s => (int?)s.Id).Max(m => m);

            item.Id = (qryNr ?? 0) + 1;
            m_contentContext.Pages.Add(item);
            m_contentContext.SaveChanges();
        }
Exemplo n.º 5
0
        public ActionResult Edit(PagesEditViewModel pagesEditViewModel)
        {
            if (ModelState.IsValid)
            {
                _pageManager.InsertOrUpdate(pagesEditViewModel);
                return RedirectToAction(nameof(PagesController.Index));
            }

            pagesEditViewModel.Init(_iconsService.Value.All);
            return View(pagesEditViewModel);
        }
        // GET: Admin/PageManager/Add
        public ActionResult Create()
        {
            this.StatusList(1);
            var model = new PagesEditViewModel()
            {
                Status  = 1,
                IsFixed = false
            };

            return(View(model));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit(PagesEditViewModel model)
        {
            if (ModelState.IsValid)
            {
                await _pageService.EditPageAsync(model.Page);

                AlertSuccess = $"Page '{model.Page.Title}' edited";
                return(RedirectToAction("Index"));
            }
            PageTitle = "Edit Page";
            return(View(model));
        }
 public ActionResult Edit(PagesEditViewModel model)
 {
     if (ModelState.IsValid)
     {
         try
         {
             m_pageWorker.UpdateManagerPages(model);
             return(RedirectToAction("Index"));
         }
         catch (Exception ex)
         {
             ModelState.AddModelError("", ex.Message);
         }
     }
     this.StatusList(model.Status);
     return(View(model));
 }
Exemplo n.º 9
0
 public async Task <IActionResult> Edit(string stub)
 {
     try
     {
         PagesEditViewModel viewModel = new PagesEditViewModel()
         {
             Page    = await _pageService.GetByStubAsync(stub),
             CanEdit = UserHasPermission(Permission.EditPages)
         };
         PageTitle = "Edit Page";
         return(View(viewModel));
     }
     catch (GraException gex)
     {
         ShowAlertWarning("Unable to view page: ", gex);
         return(RedirectToAction("Index"));
     }
 }
Exemplo n.º 10
0
        public async Task <IActionResult> Edit(string stub)
        {
            try
            {
                var page = await _pageService.GetByStubAsync(stub, false);

                var baseUrl = await _siteService.GetBaseUrl(Request.Scheme, Request.Host.Value);

                PagesEditViewModel viewModel = new PagesEditViewModel()
                {
                    Page    = page,
                    CanEdit = UserHasPermission(Permission.EditPages),
                    PageUrl = $"{baseUrl}{Url.Action("Index", "Info", new { area = "", stub = page.Stub })}"
                };
                PageTitle = "Edit Page";
                return(View(viewModel));
            }
            catch (GraException gex)
            {
                ShowAlertWarning("Unable to view page: ", gex);
                return(RedirectToAction("Index"));
            }
        }