/// <summary> /// Creates a new instance of this DomainModelActiveRecord and /// initializes it so that all of its necessary components are configured. /// Service, Repository, Settings, Validator etc. /// </summary> /// <returns></returns> public static T New() { T model = new T(); ActiveRecordRegistration.InitModel <TId, T>(model, model.ModelName); return(model); }
/// <summary> /// Retrieve all instances of model. /// </summary> /// <returns></returns> public static BoolMessageItem <IList <T> > GetAll() { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); BoolMessageItem <IList <T> > result = service.GetAll(CreateContext()); foreach (T item in result.Item) { ActiveRecordRegistration.InitModel <T>(item, service); } return(result); }
/// <summary> /// Retrieve the model associated with the id. /// </summary> /// <param name="id"></param> /// <returns></returns> public static BoolMessageItem <T> Get(int id) { IEntityService <T> service = ActiveRecordRegistration.GetService <T>(); ActionContext context = CreateContext(); context.Id = id; BoolMessageItem <T> result = service.Get(context); ActiveRecordRegistration.InitModel <T>(result.Item, service); return(result); }