File: D:/HostingSpaces/TDijk1/erp-apps.eu/wwwroot/CMSWebParts/Pux/Ecommerce/ManufacturerList.ascx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CMS.PortalControls;
using CMS.Ecommerce;
using CMS.Helpers;
public partial class CMSWebParts_Pux_Ecommerce_ManufacturerList : CMSAbstractWebPart
{
public string Transformation
{
get
{
return ValidationHelper.GetString(GetValue("Transformation"), string.Empty);
}
set
{
SetValue("Transformation", value);
}
}
#region "Control lifecycle"
/// <summary>
/// Content loaded event handler.
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
}
/// <summary>
/// Initializes the control properties.
/// </summary>
protected void SetupControl()
{
if (this.StopProcessing)
{
// Do not process
}
else
{
var result = GetManufacturerUrls();
rptItems.DataSource = result;
rptItems.DataBind();
rptItems.TransformationName = Transformation;
rptItems.EnableViewState = false;
}
}
private List<ManufacturerItem> GetManufacturerUrls()
{
var result = new List<ManufacturerItem>();
var manufacturers = ManufacturerInfoProvider.GetManufacturers();
foreach (var manufacturer in manufacturers)
{
result.Add(new ManufacturerItem()
{
CodeName = manufacturer.ManufacturerName,
Name = manufacturer.ManufacturerDisplayName,
Logo = "/CMSPages/GetMetaFile.aspx?fileguid=" + manufacturer.ManufacturerThumbnailGUID,
Description = manufacturer.ManufacturerDescription,
Website = manufacturer.ManufacturerHomepage,
IsLogo = (manufacturer.ManufacturerThumbnailGUID == Guid.Empty) ? false : true
});
}
return result;
}
/// <summary>
/// Reloads the control data.
/// </summary>
public override void ReloadData()
{
base.ReloadData();
SetupControl();
}
#endregion
class ManufacturerItem
{
public string Name { get; set; }
public string Description { get; set; }
public string Logo { get; set; }
public string Website { get; set; }
public string CodeName { get; set; }
public bool IsLogo { get; set; }
}
}