-
-
Save islaytitans/62cdf3320f8c38f280f7 to your computer and use it in GitHub Desktop.
Sitecore Hackathon SitecoreItemRepository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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