Wire up the manager class to the data provider class by creating the following methods:
public ProductItem CreateProduct()
{
return this.Provider.CreateProduct();
}
public ProductItem CreateProduct(Guid id)
{
return this.Provider.CreateProduct(id);
}
public virtual ProductItem CheckOut(ProductItem productItem)
{
return (ProductItem)this.Lifecycle.CheckOut(productItem);
}
public virtual ProductItem CheckIn(ProductItem productItem)
{
return (ProductItem)this.Lifecycle.CheckIn(productItem);
}
public ProductItem GetProduct(Guid id)
{
return this.Provider.GetProduct(id);
}
public IQueryable<ProductItem> GetProducts()
{
return this.Provider.GetProducts();
}
public void DeleteProduct(ProductItem product)
{
this.Provider.DeleteProduct(product);
}
public void DeleteProduct(Guid id)
{
this.Provider.DeleteProduct(this.Provider.GetProduct(id));
}
public ILifecycleDecorator Lifecycle
{
get
{
return LifecycleFactory.CreateLifecycle<ProductItem>(this, this.Copy);
}
}
public void Copy(Telerik.Sitefinity.GenericContent.Model.Content source, Telerik.Sitefinity.GenericContent.Model.Content destination)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
if (destination == null)
{
throw new ArgumentNullException("destination");
}
var productSource = source as ProductItem;
var productDestination = destination as ProductItem;
if (productSource == null || productDestination == null)
{
throw new ArgumentException("Source and destination must be of the same type");
}
this.Copy(productSource, productDestination);
}
public void Copy(ProductItem source, ProductItem destination)
{
destination.Urls.ClearDestinationUrls(source.Urls, this.Delete);
source.Urls.CopyTo(destination.Urls, destination);
ContentLinksExtensions.CopyContentLink("ProductImage", source, destination);
destination.Price = source.Price;
destination.QuantityInStock = source.QuantityInStock;
}