public override ProductItem CreateProduct()
{
return this.CreateProduct(Guid.NewGuid());
}
public override ProductItem CreateProduct(Guid id)
{
var product = new ProductItem();
product.Id = id;
product.ApplicationName = this.ApplicationName;
product.Owner = SecurityManager.GetCurrentUserId();
var dateValue = DateTime.UtcNow;
product.DateCreated = dateValue;
product.PublicationDate = dateValue;
((IDataItem)product).Provider = this;
// news permissions inherit form the security root
var securityRoot = this.GetSecurityRoot();
if (securityRoot != null)
{
this.providerDecorator.CreatePermissionInheritanceAssociation(securityRoot, product);
}
else
{
var msg = Res.Get<SecurityResources>().NoSecurityRoot;
msg = string.Format(msg, typeof(ProductItem).AssemblyQualifiedName);
throw new InvalidOperationException(msg);
}
// items with empty guid are used in the UI to get a "blank" data item
// -> i.e. to fill a data item with default values
// if this is the case, we leave the item out of the transaction
if (id != Guid.Empty)
{
this.GetContext().Add(product);
}
return product;
}
public override ProductItem GetProduct(Guid id)
{
if (id == Guid.Empty)
{
throw new ArgumentException("Id cannot be Empty Guid");
}
// Always use this method. Do NOT change it to query. Catch the exception if the Id can be wrong.
var newsItem = this.GetContext().GetItemById<ProductItem>(id.ToString());
((IDataItem)newsItem).Provider = this;
return newsItem;
}
public override IQueryable<ProductItem> GetProducts()
{
var appName = this.ApplicationName;
var query =
SitefinityQuery
.Get<ProductItem>(this, MethodBase.GetCurrentMethod())
.Where(b => b.ApplicationName == appName);
return query;
}
public override void DeleteProduct(ProductItem product)
{
var scope = this.GetContext();
this.ClearContentLinks(product);
//remove the item from the parent list of inheritors
var securityRoot = this.GetSecurityRoot();
if (securityRoot != null)
{
List<PermissionsInheritanceMap> parentInheritors = securityRoot.PermissionChildren.Where(c => c.ChildObjectId == product.Id).ToList();
for (int inheritor = 0; inheritor < parentInheritors.Count(); inheritor++)
{
securityRoot.PermissionChildren.Remove(parentInheritors[inheritor]);
}
}
//remove the relevant permissions
this.providerDecorator.DeletePermissions(product);
this.ClearLifecycle(product, this.GetProducts());
if (scope != null)
{
scope.Remove(product);
}
this.DeleteItemComments(product.GetType(), product.Id);
}
public override Telerik.Sitefinity.Lifecycle.LanguageData CreateLanguageData()
{
return this.CreateLanguageData(Guid.NewGuid());
}
public override Telerik.Sitefinity.Lifecycle.LanguageData CreateLanguageData(Guid id)
{
var languageData = new LanguageData(this.ApplicationName, id);
((IDataItem)languageData).Provider = this;
if (id != Guid.Empty)
{
this.GetContext().Add(languageData);
}
return languageData;
}
public override Telerik.Sitefinity.Lifecycle.LanguageData GetLanguageData(Guid id)
{
if (id == Guid.Empty)
throw new ArgumentException("Argument 'id' cannot be empty GUID.");
var languageData = this.GetContext().GetItemById<LanguageData>(id.ToString());
((IDataItem)languageData).Provider = this;
return languageData;
}
public override IQueryable<Telerik.Sitefinity.Lifecycle.LanguageData> GetLanguageData()
{
var appName = this.ApplicationName;
return SitefinityQuery.Get<LanguageData>(this).Where(c => c.ApplicationName == appName);
}