Pass parameter or second part to Driver?

Topics: Writing modules
Jul 26, 2012 at 5:37 PM

Hello,

I'm using BuildDisplay() in my controller to invoke the Display method in the Driver. For one particular scenario, I need to also pass another list of items with the part that the Display method is generating.

I have this working on another Driver where for a single SeasonPart, I'm also pulling all EpisodeParts that are related to that SeasonPart. This works great

In the one I'm working on now, I'm pulling a single TeamPart and I need to pull all TeamMemberParts that are related to that TeamPart. The problem is that I also need to qualify the EpisodePart for those TeamMemberparts, not just the TeamPart.

Therefore I need to figure out a way to pass in something from the Controller to the Driver that I can qualify EpisodePart on.

Is there way to pass just a string or integer with the EpisodePart Id to the Driver? Or can I pass 2 parts to the Driver?

Sorry if this explanation isn't totally clear...it's a bit difficult to explain.

Here is the model setup of those 3 parts if it helps

public class EpisodePartRecord : ContentPartRecord {
    public virtual bool Active { get; set; }
    public virtual bool Finale{ get; set; }
    public virtual DateTime? AirDate { get; set; }
    public virtual DateTime? PickDate { get; set; }
    public virtual DateTime? EarlyPickDate { get; set; }
    public virtual int Number { get; set; }
    public virtual string MysteryQuestion { get; set; }

    public virtual SeasonPartRecord Season { get; set; }
}

public class TeamPartRecord : ContentPartRecord {
    public virtual string Name { get; set; }
    public virtual string Color{ get; set; }

    public virtual SeasonPartRecord Season { get; set; }
}

public class TeamMemberPartRecord : ContentPartRecord {
    public virtual EpisodePartRecord Season { get; set; }
    public virtual TeamPartRecord Season { get; set; }
    public virtual CastPartRecord Season { get; set; }
}

The BuildDisplay() method for the TeamPart is being called from the EpisodeController in the Edit method.

Thanks for any help you can provide.

Coordinator
Jul 26, 2012 at 5:45 PM

Parts are supposed to be self-contained so that looks like a weird scenario, but you canalways stick stuff on HttpContext.Item.

Jul 26, 2012 at 5:50 PM

So it sounds like I can throw the EpisodePart or the Id of the EpisodePart into a HttpContext.Item and access it in the driver. Definitely an option. Thanks

Jul 26, 2012 at 9:54 PM

Well...might not be the most elegant solution or completely in toe with best practices, but it worked great. Thanks for the suggestion!