Skip to content

Instantly share code, notes, and snippets.

@islaytitans
Created July 29, 2015 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save islaytitans/62cdf3320f8c38f280f7 to your computer and use it in GitHub Desktop.
Save islaytitans/62cdf3320f8c38f280f7 to your computer and use it in GitHub Desktop.
Sitecore Hackathon SitecoreItemRepository
namespace DevToolKit.Repositories
{
public class SitecoreItemRepository : Sitecore.Services.Core.IRepository<ItemModel>
{
private IDataAccess _dataAccess = new DataAccess.DataAccess();
private ISitecoreItemMapper _sitecoreItemMapper = new SitecoreItemMapper();
public void Add(ItemModel entity)
{
throw new NotImplementedException();
}
public void Delete(ItemModel entity)
{
throw new NotImplementedException();
}
public bool Exists(ItemModel entity)
{
Assert.IsNotNull(entity, "entity is required");
return (_dataAccess.GetItem(entity.Id) != null);
}
public ItemModel FindById(string id)
{
Assert.IsNotNullOrEmpty(id, "id is required");
Item item = _dataAccess.GetItem(id);
if (item == null) return new ItemModel();
var sItem = _sitecoreItemMapper.MapToEntity(item);
return sItem;
}
public IQueryable<ItemMode> GetAll()
{
throw new NotImplementedException();
}
public void Update(ItemModel entity)
{
Assert.IsNotNull(entity,"Entity can not be null");
Assert.IsNotNullOrEmpty(entity.Id, "Id can not be null");
_dataAccess.UpdateItem(entity);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment