Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8559599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:05:26+00:00 2026-06-11T16:05:26+00:00

I’m developing a web app based on Orchard. I’m coding a module that manages

  • 0

I’m developing a web app based on Orchard.

I’m coding a module that manages Staff Users, this users are ContentTypes(Staff_User) composed of UserPart and StaffUserPart (Custom part, defined in a migration) -> this part has a MediaPickerField.

This is the code in my controller to show the creation template of a staff users

 public ActionResult CreateStaff() {

        IContent staffUser = _contentManager.New("Staff_User");

        var model = _contentManager.BuildEditor(staffUser);

        return View((object)model);
    }

Ok, I have a template in EditorTemplates/Staff.cshtml . The MediaPicker field is attached by the the BuildEditor function (as a shape).

This is the Post controller:

 public ActionResult CreateStaffPost(FormCollection input) {

        IContent staffUser = _contentManager.New("Staff_User");

        //UserPart validation
        if (String.IsNullOrEmpty(input["user.Email"]))
            ModelState.AddModelError("Email", "The Email field is required.");

        //Check if user already exits
        var oldUser = _contentManager.Query("User").Where<UserPartRecord>(x => x.Email == input["user.Email"])
            .List()
            .FirstOrDefault();

        if (oldUser != null)
            ModelState.AddModelError("Email", "That email adress is already registered.");

        if (!ModelState.IsValid) {
            var model = _contentManager.UpdateEditor(staffUser, this);
            return View(model);
        }

        StaffUserPart staff = staffUser.As<StaffUserPart>();
        staff.FirstName = input["FirstName"];
        staff.LastName = input["LastName"];
        staff.Location = input["Location"];
        staff.JobTitle = input["JobTitle"];
        staff.Summary = input["Summary"];
        staff.AreaOfExpertise = input["AreaOfExperience"];
        staff.Category = input["Category"];
        staff.Experience = input["Experience"];

        //Media picker field values
        var staffImageField = (MediaPickerField)staff.Fields.Single(x => x.Name == "Photo");
        //TODO Fix image save during creation
        staffImageField.Url = input["StaffUserPart.Photo.Url"];
        staffImageField.AlternateText = input["StaffUserPart.Photo.AlternateText"];
        staffImageField.Class = input["StaffUserPart.Photo.Class"];
        staffImageField.Style = input["StaffUserPart.Photo.Style"];
        staffImageField.Alignment = input["StaffUserPart.Photo.Alignment"];
        staffImageField.Width = String.IsNullOrEmpty(input["StaffUserPart.Photo.Width"]) ? 0 : Convert.ToInt32(input["StaffUserPart.Photo.Width"]);
        staffImageField.Height = String.IsNullOrEmpty(input["StaffUserPart.Photo.Height"]) ? 0 : Convert.ToInt32(input["StaffUserPart.Photo.Height"]);

        UserPart userPart = staffUser.As<UserPart>();
        userPart.UserName = input["user.Email"];
        userPart.Email = input["user.Email"];
        userPart.NormalizedUserName = input["user.Email"].ToLowerInvariant();
        userPart.Record.HashAlgorithm = "SHA1";
        userPart.RegistrationStatus = UserStatus.Approved;
        userPart.EmailStatus = UserStatus.Approved;

        //Set Password
        _membershipService.SetPassword(userPart.As<UserPart>(), input["password"]);

        //Create the StaffUser
        _contentManager.Create(staffUser);

        return RedirectToAction("Index");
    }

Question

This works but the MediaPickerField doesn;t save the data. I use the debugger to see if the values from input[“StaffUserPart.Photo”] and the values are there.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T16:05:28+00:00Added an answer on June 11, 2026 at 4:05 pm

    It looks like you’re doing more work than you need to. If you move your call to UpdateEditor, this method will do the work of putting posted values into your content. You’ll need to make sure you’re implementing IUpdater. Also, I added a dependency on ITransactionManager. I’m hoping this will help catch something not getting put in the right spot.

    public ActionResult CreateStaffPost(FormCollection input) {
    
        IContent staffUser = _contentManager.New("Staff_User");
    
        //Create the StaffUser
        _contentManager.Create(staffUser);
    
        //UserPart validation
        if (String.IsNullOrEmpty(input["user.Email"]))
            ModelState.AddModelError("Email", "The Email field is required.");
    
        //Check if user already exits
        var oldUser = _contentManager.Query("User").Where<UserPartRecord>(x => x.Email == input["user.Email"])
            .List()
            .FirstOrDefault();
    
        if (oldUser != null)
            ModelState.AddModelError("Email", "That email adress is already registered.");
    
        //This does all the work of hydrating your model
        var model = _contentManager.UpdateEditor(staffUser, this);
        if (!ModelState.IsValid) {   
            _transactionManager.Cancel();
            return View(model);
        }
    
        //Set Password
        _membershipService.SetPassword(userPart.As<UserPart>(), input["password"]);
    
        return RedirectToAction("Index");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I know there's a lot of other questions out there that deal with this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.