public override LocationItem CreateLocation()
{
return this.CreateLocation(Guid.NewGuid());
}
public override LocationItem CreateLocation(Guid id)
{
var location = new LocationItem();
location.Id = id;
location.ApplicationName = this.ApplicationName;
location.Owner = SecurityManager.GetCurrentUserId();
var dateValue = DateTime.UtcNow;
location.DateCreated = dateValue;
location.PublicationDate = dateValue;
((IDataItem)location).Provider = this;
// 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(location);
}
return location;
}
public override LocationItem GetLocation(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 location = this.GetContext().GetItemById<LocationItem>(id.ToString());
((IDataItem)location).Provider = this;
return location;
}
public override IQueryable<LocationItem> GetLocations()
{
var appName = this.ApplicationName;
var query =
SitefinityQuery
.Get<LocationItem>(this, MethodBase.GetCurrentMethod())
.Where(b => b.ApplicationName == appName);
return query;
}
public override void DeleteLocation(LocationItem location)
{
var scope = this.GetContext();
this.ClearLifecycle(location, this.GetLocations());
if (scope != null)
{
scope.Remove(location);
}
}