Create() public method

public Create ( dynamic, item ) : PageModel,
item dynamic,
return PageModel,
Example #1
0
    public void Create_Should_Validate_Title()
    {
        dynamic data = new ExpandoObject();
        data.Id = "id";
        data.Title = null; // <-- it should catch this
        var repository = new Mock();
        var model = new PageModel();
        model.Repository = repository;

        model.Create(data);
        Assert.IsTrue(model.HasError);
    }
Example #2
0
 public void Create_Should_Validate_New_Title_Exists()
 {
     dynamic data = new ExpandoObject();
     data.Id = null;
     data.Title = "new title";
     var repository = new Mock();
     repository.Setup("Exists", new object[] { "new title" }, true); // <-- it should catch this
     var model = new PageModel();
     model.Repository = repository;
     model.Create(data);
     Assert.IsTrue(model.HasError);
     repository.Verify();
 }
Example #3
0
    public void Create_Should_Validate_Title()
    {
        dynamic data = new ExpandoObject();

        data.Id    = "id";
        data.Title = null; // <-- it should catch this
        var repository = new Mock();
        var model      = new PageModel();

        model.Repository = repository;

        model.Create(data);
        Assert.IsTrue(model.HasError);
    }
Example #4
0
    public void Create_Should_Validate_New_Title_Exists()
    {
        dynamic data = new ExpandoObject();

        data.Id    = null;
        data.Title = "new title";
        var repository = new Mock();

        repository.Setup("Exists", new object[] { "new title" }, true); // <-- it should catch this
        var model = new PageModel();

        model.Repository = repository;
        model.Create(data);
        Assert.IsTrue(model.HasError);
        repository.Verify();
    }
Example #5
0
    protected void btnFinish_Click(object sender, EventArgs e)
    {
        string title = (pageBuilderWizardPageTitle.Text).Trim();
        string aliasName = String.Empty;
        string extension = String.Empty;
        long pageId = 0;
        int languageId = 1033;
        long folderId = -1;
        long wireFrameId = 0;
        // prep some variables for later use
        PageModel pageModel = new PageModel();
        PageData pageInfo = new PageData();
        WireframeModel model = new WireframeModel();
        WireframeData wireframeInfo = new WireframeData();

        if (ManualAliasing.GetActiveView() == ManualAliasingEnabled && pageBuilderCreateManualAlias.Checked)
        {
            // if url aliasing is enabled, pre-pop using urlAlias field
            aliasName = (pageBuilderWizardAlias.Text).Trim();
            extension = ExtensionDropdown.SelectedValue;
            if (extension != "none")
            {
                if (!aliasName.EndsWith(extension, true, null))
                {
                    aliasName += extension;
                }
            }
        }

        if (Request.QueryString["mode"] != "" && Request.QueryString["mode"] != null)
        {
            mode = Request.QueryString["mode"];
        }

        if (Request.QueryString["pageid"] != "" && Request.QueryString["pageid"] != null)
        {
            pageId = Convert.ToInt64(Request.QueryString["pageid"]);
        }

        if (Request.Form["ektronSelectedTemplate"] != "" && Request.Form["ektronSelectedTemplate"] != null)
        {
            wireFrameId = Convert.ToInt64(Request.Form["ektronSelectedTemplate"]);
        }

        string summary = Summary.Content;

        if (Request.QueryString["folderid"] != "" && Request.QueryString["folderid"] != null)
        {
            folderId = Convert.ToInt64(Request.QueryString["folderid"]);
        }

        if (Request.QueryString["language"] != "" && Request.QueryString["language"] != null)
        {
            languageId = Convert.ToInt32(Request.QueryString["language"]);
        }
        if (languageId == -1)
        {
            languageId = contentAPI.RequestInformationRef.ContentLanguage;
        }

        System.Collections.Hashtable meta = metadata.Metadata;

        List<long> selTaxonomy = selectTaxonomy.SelectedTaxonomies;

        string metaXML = "";
        string Quicklink = "";

        //<metadata><meta id="3">Title</meta></metadata>
        foreach (object key in meta.Keys)
        {
            metaXML += @"<meta id=""" + ((object[])meta[key])[0] + @""">" + EkFunctions.HtmlEncode(((object[])meta[key])[2].ToString()) + "</meta>";
        }
        metaXML = "<metadata>" + metaXML + "</metadata>";

        //  create or copy as needed
        if (mode == "add")
        {
            // no pageId was passed, so we're in add mode
            // create the wireframe
            pageModel.Create(title, folderId, aliasName, languageId, wireFrameId, metaXML, summary, out pageInfo);
        }
        else
        {
            // we're in copy mode
            // let's get the wireframeId based on the current template
            pageModel.Get(pageId, out pageInfo, false);
            wireframeInfo = model.FindByPageID(pageInfo.pageID);
            wireFrameId = wireframeInfo.ID;
            pageInfo.title = title;
            // now we'll make the copy
            pageModel.Copy(pageInfo, folderId, aliasName, languageId, wireFrameId, metaXML, summary, out  pageInfo);
        }

        if (selTaxonomy.Count > 0)
        {
            TaxonomyContentRequest tcr = new TaxonomyContentRequest();
            tcr.ContentId = pageInfo.pageID;
            tcr.TaxonomyList = String.Join(",", selTaxonomy.ConvertAll<string>(delegate(long l) { return l.ToString(); }).ToArray());
            contentAPI.AddTaxonomyItem(tcr);
        }

        // we need to get the quicklink for the redirect just in case
        wireframeInfo = model.FindByID(wireFrameId);
        if (wireframeInfo.Template.MasterLayoutID > 0)
        {
            wireframeInfo = model.FindByPageID(wireframeInfo.Template.MasterLayoutID);
        }
        Quicklink = wireframeInfo.Path + (wireframeInfo.Path.IndexOf("?") > 0 ? "&Pageid=" : "?Pageid=") + pageInfo.pageID;

        if (aliasName.Length > 0 && aliasName.IndexOf("LangType=") == -1)
        {
            if (aliasName.IndexOf("?") > 0)
            {
                aliasName += "&LangType=" + languageId.ToString();
            }
            else
            {
                aliasName += "?LangType=" + languageId.ToString();
            }
        }
        if (Quicklink.IndexOf("LangType=") == -1)
        {
            if (Quicklink.IndexOf("?") > 0)
            {
                Quicklink += "&LangType=" + languageId.ToString();
            }
            else
            {
                Quicklink += "?LangType=" + languageId.ToString();
            }
        }
        ektronWizardStepWrapper.Visible = false;
        redirectMessage.Visible = true;

        // Populate the fullAlias hidden field
        PopulateFullAlias(aliasName, Quicklink);

        // build script to modify the modal and display the correct buttons, etc.
        StringBuilder scriptString = new StringBuilder();
        scriptString.AppendLine("parent.$ektron('.ektronPageBuilderAddPage').hide();");
        scriptString.AppendLine("Ektron.ready(function(){");
        scriptString.AppendLine("  parent.Ektron.PageBuilder.Wizards.Buttons.showPromptButtons();");
        scriptString.AppendLine("  parent.$ektron('.ektronPageBuilderWizard iframe.ektronPageBuilderAddPageIframe').height('6em');");
        scriptString.AppendLine("  parent.$ektron('.ektronPageBuilderAddPage').fadeIn('slow');");
        scriptString.AppendLine(" });");
        // insert the script into the page
        ClientScript.RegisterClientScriptBlock(this.GetType(), "EktronPageBuilderRedirectPrompt", scriptString.ToString(), true);
    }
Example #6
0
 public async Task <PageModel <T> > GetAllPaged(int?pageSize, int?pageIndex)
 {
     return(PageModel <T> .Create(await BaseRepository.GetAllPaged(pageSize, pageIndex)));
 }