Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sam 79 posts 426 karma points
    Feb 27, 2018 @ 16:38
    Sam
    0

    Make Content only available to a members group from a form post in the surface controler- Public Access rules

    Hello all,

    I currently have a form on my site that will create content in Backoffice. just like a contact form might. I need the pages for these nodes to be restricted to a specific member group.

    I found some information about IPublicAccessService AddRule, but because of my lack of experience with .net, I do not know how to use it. I could not find any examples.

    https://our.umbraco.org/apidocs/csharp/api/Umbraco.Core.Services.IPublicAccessService.html

    here is the form post section of my controler:

    public ActionResult HandleFormPost(WarrantyModel model) //Links functions to the form in the partial view...BeginUmbracoForm
        {
            if (ModelState.IsValid) // For Field Validation 
            {
                // This will post submittion to Umbraco Database 
                var newWarranty = 
    Services.ContentService.CreateContent(model.WarLastName + "-" + DateTime.Now, 1204, "warrantyFormula");
                var myService = ApplicationContext.Services.DataTypeService;
                string InstallType = model.WarInstallType;
                string Applications = model.WarApplication;
                string PurchasedFroms = model.WarPurchasedFrom;
                int ColorValue = model.WarColor;
                var ColorNode = new Node(ColorValue);
    
                newWarranty.SetValue("WarFirstName", model.WarFirstName);
                newWarranty.SetValue("WarLastName", model.WarLastName);
                newWarranty.SetValue("WarPhone", model.WarPhone);
                newWarranty.SetValue("WarAddress", model.WarAddress);
                newWarranty.SetValue("WarCity", model.WarCity);
                newWarranty.SetValue("WarSt", model.WarSt);
                newWarranty.SetValue("WarZip", model.WarZip);
                newWarranty.SetValue("WarCountry", model.WarCountry);
                newWarranty.SetValue("WarEmail", model.WarEmail);
    
                newWarranty.SetValue("WarInstallDate", model.WarInstallDate);
                newWarranty.SetValue("WarSqFt", model.WarSqFt);
                newWarranty.SetValue("WarInstallType", InstallType);
                newWarranty.SetValue("WarApplication", Applications);
                newWarranty.SetValue("WarColor", ColorNode.Name);
    
                newWarranty.SetValue("WarPurchasedFrom", PurchasedFroms);
                newWarranty.SetValue("WarRetailCompany", model.WarRetailCompany);
                newWarranty.SetValue("WarRetailAddress", model.WarRetailAddress);
                newWarranty.SetValue("WarRetailCity", model.WarRetailCity);
                newWarranty.SetValue("WarRetailSt", model.WarRetailSt);
                newWarranty.SetValue("WarRetailZip", model.WarRetailZip);
                newWarranty.SetValue("WarRetailCountry", model.WarRetailCountry);
                newWarranty.SetValue("WarRetailPhone", model.WarRetailPhone);
    
               IPublicAccessService.AddRule(???,???,???)
                Services.ContentService.SaveAndPublishWithStatus(newWarranty);
    

    thanks in advance.

  • Sam 79 posts 426 karma points
    Mar 23, 2018 @ 18:53
    Sam
    0

    Does anybody have any insight?

Please Sign in or register to post replies

Write your reply to:

Draft