/// <summary> /// Get items by page. /// </summary> /// <param name="table">"BlogPosts"</param> /// <param name="pageNumber">1 The page number to get.</param> /// <param name="pageSize">15 Number of records per page.</param> /// <param name="totalPages">Total number of pages found.</param> /// <param name="totalRecords">Total number of records found.</param> /// <returns></returns> public static BoolResult <PagedList <T> > GetRecent(int pageNumber, int pageSize) { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); BoolResult <PagedList <T> > result = service.GetRecent(pageNumber, pageSize); return(result); }
/// <summary> /// Get items by page using filter. /// </summary> /// <param name="filter">e.g. "UserNameLowered = 'kishore'"</param> /// <returns></returns> public static BoolResult <IList <T> > GetByFilter(string filter) { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); BoolResult <IList <T> > result = service.GetByFilter(filter); return(result); }
/// <summary> /// Performs the actual entity action specified by the delegate <paramref name="executor"/> /// </summary> /// <param name="entity"></param> /// <param name="executor"></param> /// <returns></returns> protected static BoolResult <T> DoEntityAction(T entity, Func <IActionContext, IEntityService <T>, BoolResult <T> > executor) { IActionContext ctx = ActiveRecordRegistration.GetContext <T>(); ctx.CombineMessageErrors = true; ctx.Item = entity; IEntityService <T> service = EntityRegistration.GetService <T>(); return(executor(ctx, service)); }
/// <summary> /// Retrieve the model associated with the id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static BoolResult <T> Get(int id) { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); IActionContext context = ActiveRecordRegistration.GetContext <T>(); context.Id = id; BoolResult <T> result = service.Get(context); ActiveRecordRegistration.Init <T>(result.Item, service); return(result); }
/// <summary> /// Retrieve all instances of model. /// </summary> /// <returns></returns> public static BoolResult <IList <T> > GetAll() { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); IActionContext ctx = ActiveRecordRegistration.GetContext <T>(); BoolResult <IList <T> > result = service.GetAll(ctx); foreach (T item in result.Item) { ActiveRecordRegistration.Init <T>(item, service); } return(result); }