Adding an IList object to the Orchard CMS DB

Jan 21, 2012 at 7:12 PM

Hi there,

I will like to begin by saying that the Orchard team has been very ready, willing and able to assist.. May I ask, is there a technique in the Orchard CMS to adding IList<> to its CMS DB, and retrieve it when needed? I am contemplating a way to accomplishing it. I would appreciate immensely any suggestion.

Here is an excerpt of the model that I currently have:

namespace Licensing.Models {
    
   public class Asset {
	private int sku;
        private string title, shortDescription;
        public Asset ( string title, string shortDescription, int sku ) {
            this.title = title;
            this.shortDescription = shortDescription;
            this.sku = sku;
        }
        public string Title { set { title = value; } get { return title; } }
        public string ShortDescription { set { shortDescription = value; } get { return shortDescription; } }
        public string Sku { set { sku = value; } get { return sku;  } }
    }

    public class LicensingPartRecord : ContentPartRecord {
        public virtual string Licensee { get; set; }
        public virtual string Coordinates { get; set; } 
        public virtual string Skus { get; set; } //comma separated list of skus
        public virtual IList Assets { set;  get; }
    }

    public class LicensingPart : ContentPart {
        
private IAssetAccessor assetAccessor = null; //this will be set in the DriverResult Editor() method of the LicensingPartDriver class. public IAssetAccessor AssetAccessor { get { return assetAccessor; } set { assetAccessor = value; } } [Required] public string Licensee { get { return Record.Licensee; } set { Record.Licensee = value; } } [Required] public string Coordinates { get { return Record.Coordinates; } set { Record.Coordinates = value; } } [Required] public string Skus { get { return Record.Skus; } set { Record.Skus = value; } } public IList Assets { get { return Record.Assets; } set { if ( AssetAccessor == null ) { //if only acquiring widget's options data from DB then simply fill with DB data - no asset accessor is necessary. Record.Assets = value; } else { //asset accessor object is not null when updating this widget's CMS DB table AssetAccess assetAccess; //remote object that produces an assets full properties string [] skus = Skus.Split ( ',' ); foreach ( string sku in skus ) { assetAccess = AssetAccessor.GetAssetAccess ( ( int ) sku ); //AssetAccessor retrieves the remote object for asset matching the sku parameter Record.Assets.Add ( new Asset ( assetAccess.Title, assetAccess.ShortDescription, assetAccess.Sku ) ); } } } } } }

 

 

 

 

Jan 26, 2012 at 5:08 AM

I posted the issue above over the weekend for discussion, but have not heard a thing yet. Does anyone care to take a crack at it?

I will surely appreciate the effort.