Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        /// <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);
        }
Ejemplo n.º 3
0
        /// <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);
        }
Ejemplo n.º 4
0
        /// <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);
        }