Example #1
0
        public virtual ActionResult Details(bool?AutoPost, string Tab)
        {
            this._logActionsAsPageViews = false;
            bool autoPost = true;

            if (AutoPost.HasValue)
            {
                autoPost = AutoPost.Value;
            }

            string rawUrl       = Request.RawUrl;
            string viewName     = CurrentPageOrThrow.PageTemplate.ViewName;
            bool   showEditLink = CurrentStoreFrontOrThrow.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.Pages_Edit);

            return(View(viewName, new PageViewModel(CurrentPageOrThrow, showEditLink, true, false, false, false, null, false, Tab)));
        }
        public virtual ActionResult Create(WebFormEditAdminViewModel WebFormEditAdminViewModel)
        {
            Client client      = CurrentClientOrThrow;
            bool   nameIsValid = GStoreDb.ValidateWebFormName(this, WebFormEditAdminViewModel.Name, CurrentClientOrThrow.ClientId, null);

            if (nameIsValid && ModelState.IsValid)
            {
                try
                {
                    WebForm webForm = null;
                    webForm = GStoreDb.CreateWebForm(WebFormEditAdminViewModel, CurrentStoreFrontOrThrow, CurrentUserProfileOrThrow);
                    AddUserMessage("Web Form Created!", "Web Form '" + webForm.Name.ToHtml() + "' [" + webForm.WebFormId + "] was created successfully for Client '" + client.Name.ToHtml() + "' [" + client.ClientId + "]", UserMessageType.Success);
                    if (CurrentStoreFrontOrThrow.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.WebForms_View))
                    {
                        return(RedirectToAction("Details", new { id = webForm.WebFormId }));
                    }
                    return(RedirectToAction("Index", "StoreAdmin"));
                }
                catch (Exception ex)
                {
                    string errorMessage = "An error occurred while Creating Web Form '" + WebFormEditAdminViewModel.Name.ToHtml() + "' for Client '" + client.Name.ToHtml() + "' [" + client.ClientId + "] \nError: " + ex.GetType().FullName;

                    if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin())
                    {
                        errorMessage += " \nException.ToString(): " + ex.ToString();
                    }
                    AddUserMessage("Error Creating Web Form!", errorMessage.ToHtmlLines(), UserMessageType.Danger);
                    ModelState.AddModelError("Ajax", errorMessage);
                }
            }
            else
            {
                AddUserMessage("Web Form Create Error", "There was an error with your entry for new Web Form '" + WebFormEditAdminViewModel.Name.ToHtml() + "' for Client '" + client.Name.ToHtml() + "' [" + client.ClientId + "]. Please correct it below and save.", UserMessageType.Danger);
            }
            WebFormEditAdminViewModel.IsStoreAdminEdit = true;
            WebFormEditAdminViewModel.IsCreatePage     = true;
            WebFormEditAdminViewModel.IsActiveDirect   = !(WebFormEditAdminViewModel.IsPending || (WebFormEditAdminViewModel.StartDateTimeUtc > DateTime.UtcNow) || (WebFormEditAdminViewModel.EndDateTimeUtc < DateTime.UtcNow));

            return(View("Create", WebFormEditAdminViewModel));
        }
        public virtual ActionResult AdvancedCreate(NavBarItemEditAdminViewModel navBarItemEditViewModel)
        {
            StoreFront storeFront  = CurrentStoreFrontOrThrow;
            bool       nameIsValid = GStoreDb.ValidateNavBarItemName(this, navBarItemEditViewModel.Name, storeFront.StoreFrontId, storeFront.ClientId, null);

            if (nameIsValid && ModelState.IsValid)
            {
                try
                {
                    NavBarItem navBarItem = GStoreDb.CreateNavBarItem(navBarItemEditViewModel, storeFront, CurrentUserProfileOrThrow);
                    AddUserMessage("Menu Item Created!", "Menu Item '" + navBarItem.Name.ToHtml() + "' [" + navBarItem.NavBarItemId + "] was created successfully for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success);
                    if (CurrentStoreFrontOrThrow.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.NavBarItems_View))
                    {
                        return(RedirectToAction("AdvancedDetails", new { id = navBarItem.NavBarItemId, ReturnToManager = navBarItemEditViewModel.ReturnToManager }));
                    }
                    return(RedirectToAction("AdvancedManager"));
                }
                catch (Exception ex)
                {
                    string errorMessage = "An error occurred while Creating Menu Item '" + navBarItemEditViewModel.Name + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "] \nError: " + ex.GetType().FullName;

                    if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin())
                    {
                        errorMessage += " \nException.ToString(): " + ex.ToString();
                    }
                    AddUserMessage("Error Creating Menu Item!", errorMessage.ToHtmlLines(), UserMessageType.Danger);
                    ModelState.AddModelError("Ajax", errorMessage);
                }
            }
            else
            {
                AddUserMessage("Create Menu Item Error", "There was an error with your entry for new menu item '" + navBarItemEditViewModel.Name.ToHtml() + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]. Please correct it below and save.", UserMessageType.Danger);
            }

            navBarItemEditViewModel.FillListsIfEmpty(storeFront.Client, storeFront);
            navBarItemEditViewModel.IsCreatePage = true;

            return(View("AdvancedCreate", navBarItemEditViewModel));
        }
Example #4
0
        public virtual ActionResult Create(PageEditViewModel pageEditViewModel)
        {
            if (pageEditViewModel.PageTemplateId == 0)
            {
                ModelState.AddModelError("PageTemplateId", "Page Template must be selected");
            }

            if (pageEditViewModel.ThemeId == 0)
            {
                ModelState.AddModelError("ThemeId", "Page Theme must be selected");
            }

            if (string.IsNullOrWhiteSpace(pageEditViewModel.Url))
            {
                ModelState.AddModelError("Url", "Url is blank. Enter a valid Url for this page. Example: '/' or '/Contact'");
            }
            else
            {
                if (pageEditViewModel.Url.Trim('/').Trim() == ".")
                {
                    ModelState.AddModelError("Url", "Url '" + pageEditViewModel.Url.ToHtml() + "' is invalid. Example: '/' or '/Contact'");
                }
                if (pageEditViewModel.Url.Contains('?'))
                {
                    ModelState.AddModelError("Url", "Url '" + pageEditViewModel.Url.ToHtml() + "' is invalid. Question mark is not allowed in URL. Example: '/' or '/Contact'");
                }
            }

            StoreFront storeFront = CurrentStoreFrontOrThrow;
            bool       urlIsValid = GStoreDb.ValidatePageUrl(this, pageEditViewModel.Url, storeFront.StoreFrontId, storeFront.ClientId, null);

            if (urlIsValid && ModelState.IsValid)
            {
                try
                {
                    Page page = null;
                    page = GStoreDb.CreatePage(pageEditViewModel, storeFront, CurrentUserProfileOrThrow);
                    AddUserMessage("Page Created!", "Page '" + page.Name.ToHtml() + "' [" + page.PageId + "] was created successfully for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success);

                    if (pageEditViewModel.CreateMenuItemWithPage)
                    {
                        NavBarItem navBarItem = GStoreDb.CreateNavBarItemForPage(page, CurrentStoreFrontOrThrow, CurrentUserProfileOrThrow);
                        AddUserMessage("Site Menu Updated!", "Page '" + page.Name.ToHtml() + "' [" + page.PageId + "] was added to the site menu for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]", UserMessageType.Success);
                    }
                    if (CurrentStoreFrontOrThrow.Authorization_IsAuthorized(CurrentUserProfileOrThrow, GStoreAction.Pages_View))
                    {
                        return(RedirectToAction("Details", new { id = page.PageId }));
                    }
                    return(RedirectToAction("Manager"));
                }
                catch (Exception ex)
                {
                    string errorMessage = "An error occurred while Creating page '" + pageEditViewModel.Name + "' Url: '" + pageEditViewModel.Url + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "] \nError: " + ex.GetType().FullName;

                    if (CurrentUserProfileOrThrow.AspNetIdentityUserIsInRoleSystemAdmin())
                    {
                        errorMessage += " \nException.ToString(): " + ex.ToString();
                    }
                    AddUserMessage("Error Creating Page!", errorMessage.ToHtmlLines(), UserMessageType.Danger);
                    ModelState.AddModelError("Ajax", errorMessage);
                }
            }
            else
            {
                AddUserMessage("Page Create Error", "There was an error with your entry for new page '" + pageEditViewModel.Name.ToHtml() + "' for Store Front '" + storeFront.CurrentConfig().Name.ToHtml() + "' [" + storeFront.StoreFrontId + "]. Please correct it below and save.", UserMessageType.Danger);
            }

            pageEditViewModel.IsStoreAdminEdit = true;
            pageEditViewModel.FillListsIfEmpty(storeFront.Client, storeFront);
            pageEditViewModel.IsCreatePage = true;
            return(View("Create", pageEditViewModel));
        }