/// <summary> /// Retrieve all instances of model. /// </summary> /// <returns></returns> public static new IList <T> GetAll() { IEntityService <T> service = EntityRegistration.GetService <T>(); IList <T> result = service.GetAll(); return(result); }
/// <summary> /// Get items by page using Criteria. /// </summary> /// <param name="pageNumber">1 The page number to get.</param> /// <param name="pageSize">15 Number of records per page.</param> /// <returns></returns> public static PagedList <T> Find(IQuery criteria, int pageNumber, int pageSize) { IEntityService <T> service = EntityRegistration.GetService <T>(); PagedList <T> result = service.Find(criteria, pageNumber, pageSize); return(result); }
/// <summary> /// Retrieve the model associated with the id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static T Get(int id) { IEntityService <T> service = EntityRegistration.GetService <T>(); T item = service.Get(id); return(item); }
/// <summary> /// Get items by page using Criteria /// </summary> /// <param name="filter">e.g. "UserNameLowered = 'kishore'"</param> /// <returns></returns> public static IList <T> Find(IQuery criteria) { IEntityService <T> service = EntityRegistration.GetService <T>(); IList <T> result = service.Find(criteria); return(result); }
/// <summary> /// Get items by page using filter. /// </summary> /// <param name="filter">e.g. "UserNameLowered = 'kishore'"</param> /// <returns></returns> public static IList <T> Find(string filter) { IEntityService <T> service = EntityRegistration.GetService <T>(); IList <T> result = service.Find(filter); return(result); }
/// <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> /// <returns></returns> public static PagedList <T> GetRecent(int pageNumber, int pageSize) { IEntityService <T> service = EntityRegistration.GetService <T>(); PagedList <T> result = service.GetRecent(pageNumber, pageSize); return(result); }
/// <summary> /// Get items by page using filter. /// </summary> /// <returns></returns> public static T First(string filter) { IEntityService <T> service = EntityRegistration.GetService <T>(); T result = service.First(filter); return(result); }
/// <summary> /// Get items by page using filter. /// </summary> /// <param name="pageNumber">1 The page number to get.</param> /// <param name="pageSize">15 Number of records per page.</param> /// <returns></returns> public static PagedList <T> Find(string filter, int pageNumber, int pageSize) { IEntityService <T> service = EntityRegistration.GetService <T>(); PagedList <T> result = service.Find(filter, pageNumber, pageSize); return(result); }
/// <summary> /// Get entity from the type of (T) and from the id in the title. The id must by at the end of the url prefixed by "-" as in "my-post-123" /// </summary> /// <typeparam name="T">The type of entity to get.</typeparam> /// <param name="title">The title of the entity with the id in the end.</param> /// <returns></returns> public static T FromUrl <T>(string title) { int id = IdFromTitle(title); IEntityService <T> service = EntityRegistration.GetService <T>(); T entity = service.Get(id); return(entity); }
/// <summary> /// Delete the model associated with the id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static BoolResult <T> Delete(int id) { IEntityService <T> service = EntityRegistration.GetService <T>(); IActionContext context = EntityRegistration.GetContext <T>(); context.Id = id; return(service.Delete(context)); }
/// <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> /// 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 void DoEntityAction(T entity, Action <IActionContext, IEntityService <T> > executor) { IActionContext ctx = EntityRegistration.GetContext <T>(); ctx.CombineMessageErrors = true; ctx.Item = entity; IEntityService <T> service = EntityRegistration.GetService <T>(); executor(ctx, service); }
/// <summary> /// Convert this to a feed. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="author"></param> /// <param name="description"></param> /// <param name="title"></param> /// <param name="uri">The uri of the request</param> public static SyndicationFeed AsFeed <T>(Uri uri, string author, string title, string description) { IEntityService <T> service = EntityRegistration.GetService <T>(); IList <IPublishable> entries = service.GetRecentAs <IPublishable>(1, 20); //http://localhost:49739/Post/rss/ string host = uri.Host; if (host.Contains("localhost")) { host = "http://localhost.com"; } else { host = uri.AbsoluteUri; } var feed = FeedBuilder.Build(author, title, description, host, entries); return(feed); }
/// <summary> /// Gets all. /// </summary> /// <returns></returns> public virtual IList <T> GetAll() { var service = EntityRegistration.GetService <T>(); return(service.GetAll()); }
/// <summary> /// Deletes all. /// </summary> /// <returns></returns> public virtual void DeleteAll() { var service = EntityRegistration.GetService <T>(); service.DeleteAll(); }
/// <summary> /// Creates the entities conditionally based on whether they exists in the datastore. /// Existance in the datastore is done by finding any entities w/ matching values for the /// <paramref name="checkFields"/> supplied. /// </summary> /// <param name="entities"></param> /// <param name="checkFields"></param> public static void Create(IList <T> entities, params Expression <Func <T, object> >[] checkFields) { IEntityService <T> service = EntityRegistration.GetService <T>(); service.Create(entities, checkFields); }
/// <summary> /// Decrements the specified member. /// </summary> /// <param name="member">The member.</param> /// <param name="by">The by.</param> /// <param name="id">The id.</param> public static void Decrement(Expression <Func <T, object> > member, int by, int id) { IEntityService <T> service = EntityRegistration.GetService <T>(); service.Decrement(member, by, id); }
/// <summary> /// Updates the entities. /// </summary> public static void Update(IList <T> entities) { IEntityService <T> service = EntityRegistration.GetService <T>(); service.Update(entities); }
/// <summary> /// Saves the entity. /// </summary> public static void Save(T entity) { IEntityService <T> service = EntityRegistration.GetService <T>(); service.Save(entity); }
/// <summary> /// Deletes all the entities from the system. /// </summary> /// <returns></returns> public static new void DeleteAll() { IEntityService <T> service = EntityRegistration.GetService <T>(); service.DeleteAll(); }
/// <summary> /// Delete the model associated with the id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static void Delete(int id) { IEntityService <T> service = EntityRegistration.GetService <T>(); service.Delete(id); }
/// <summary> /// Saves this instance. /// </summary> /// <returns></returns> public virtual void Save() { var service = EntityRegistration.GetService <T>(); service.Save(this as T); }