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