Skip to content

Instantly share code, notes, and snippets.

@komainu85
komainu85 / Is Content Item
Last active August 29, 2015 14:17
Sitecore Is Content / Media Item
Sitecore.Context.Item.Paths.IsContentItem
@komainu85
komainu85 / Add Item from template
Created March 13, 2015 15:45
Sitecore Add Item from Template
Sitecore.Data.Items.ItemUtil.AddFromTemplate(string itemName, string templatePath, Item parent);
@komainu85
komainu85 / Edit Item
Created March 13, 2015 15:47
Edit Sitecore Item
using (new EditContext(scItem))
{
redirectItem.Fields["fieldName"].Value = "";
}
@komainu85
komainu85 / Get Item from Event
Created March 13, 2015 15:48
Sitecore get item from event
var item = Sitecore.Events.Event.ExtractParameter<Item>(args, 0);
@komainu85
komainu85 / ICustomRepositoryActions
Created March 20, 2015 13:19
ICustomRepositoryActions
public interface ICustomRepositoryActions<T> : Sitecore.Services.Core.IRepository<T> where T : IEntityIdentity
{
string DoSometingCustom();
}
@komainu85
komainu85 / ICustomRepositoryActions
Created March 20, 2015 13:19
ICustomRepositoryActions
public class EntityRespository :ICustomRepositoryActions<Entity>
{
public IQueryable<Entity> GetAll()
{
throw new NotImplementedException();
}
public Entity FindById(string id)
{
throw new NotImplementedException();
@komainu85
komainu85 / EntityController
Created March 20, 2015 13:20
EntityController
[ServicesController]
public class EntityController : EntityService<Entity>
{
private ICustomRepositoryActions<Entity> _customRepositoryActions;
public EntityController(ICustomRepositoryActions<Entity> repository)
: base(repository)
{
_customRepositoryActions = repository;
}
@komainu85
komainu85 / Web API Controller Action
Created March 20, 2015 13:37
Web API Controller Action
[HttpGet]
[ActionName("DoSomethingCustom")]
public string Get()
{
return "Hello World";
}
@komainu85
komainu85 / ICustomRepository.cs
Created March 22, 2015 16:41
Sitecore Entity Service Paged
public interface ICustomRepository<T> : Sitecore.Services.Core.IRepository<T> where T : IEntityIdentity
{
List<Entity> GetAll(int pageSize, int page);
}
@komainu85
komainu85 / EntityRespository.cs
Created March 22, 2015 16:45
Sitecore Entity Service Paged Repository
public class EntityRespository : ICustomRepository<Entity>
{
public IQueryable<Entity> GetAll()
{
throw new NotImplementedException();
}
public Entity FindById(string id)
{
throw new NotImplementedException();