public IEnumerable <dynamic> Get(string classCode, string filteringQuery, string sortingMemberCode, string sortingDirection, int?pagingSkip, int?pagingTake) { ISerializedObjectRepository serializedObjectRepository = this.Storage.GetRepository <ISerializedObjectRepository>(); Class @class = this.GetValidatedClass(classCode); Culture frontendDefaultCulture = this.GetService <ICultureManager>().GetFrontendDefaultCulture(); Params @params = new ParamsFactory(this).Create(filteringQuery, @class.Id, sortingMemberCode, sortingDirection, pagingSkip, pagingTake); IEnumerable <SerializedObject> serializedObjects = serializedObjectRepository.FilteredByCultureIdAndClassId( frontendDefaultCulture.Id, @class.Id, @params ).ToList(); ObjectDirector objectDirector = new ObjectDirector(this); this.Response.Headers.Add("Filtering-Query", WebUtility.UrlEncode(filteringQuery)); this.Response.Headers.Add("Sorting-Member-Code", sortingMemberCode); this.Response.Headers.Add("Sorting-Direction", sortingDirection); this.Response.Headers.Add("Paging-Skip", pagingSkip.ToString()); this.Response.Headers.Add("Paging-Take", pagingTake.ToString()); this.Response.Headers.Add("Paging-Total", serializedObjectRepository.CountByCultureIdAndClassId(frontendDefaultCulture.Id, @class.Id, @params).ToString()); return(serializedObjects.Select( so => { DynamicObjectBuilder objectBuilder = new DynamicObjectBuilder(); objectDirector.ConstructObject(objectBuilder, so); return objectBuilder.Build(); } )); }
public int Count <T>(string filteringQuery = null) { Class @class = this.GetValidatedClass <T>(); Culture frontendDefaultCulture = this.requestHandler.GetService <ICultureManager>().GetFrontendDefaultCulture(); Params @params = new ParamsFactory(this.requestHandler).Create(filteringQuery, @class.Id, null, null, null, null); return(serializedObjectRepository.CountByCultureIdAndClassId(frontendDefaultCulture.Id, @class.Id, @params)); }
public IndexViewModel Create(int?classId, int?objectId, string orderBy, string direction, int skip, int take, string filter) { IClassRepository classRepository = this.RequestHandler.Storage.GetRepository <IClassRepository>(); IObjectRepository objectRepository = this.RequestHandler.Storage.GetRepository <IObjectRepository>(); ISerializedObjectRepository serializedObjectRepository = this.RequestHandler.Storage.GetRepository <ISerializedObjectRepository>(); if (classId != null && string.IsNullOrEmpty(orderBy)) { orderBy = this.GetDefaultMember((int)classId)?.Code; } Culture currentCulture = null; Params @params = null; if (classId != null) { currentCulture = this.RequestHandler.GetService <ICultureManager>().GetCurrentCulture(); @params = new ParamsFactory(this.RequestHandler).Create(filter, classId, orderBy, direction, skip, take); } return(new IndexViewModel() { Class = classId == null ? null : new ClassViewModelFactory(this.RequestHandler).Create( classRepository.WithKey((int)classId) ), ClassesByAbstractClasses = this.GetClassesByAbstractClasses(), Grid = classId == null ? null : new GridViewModelFactory(this.RequestHandler).Create( orderBy, direction, skip, take, objectId == null ? serializedObjectRepository.CountByCultureIdAndClassId(currentCulture.Id, (int)classId, @params) : serializedObjectRepository.CountByCultureIdAndClassIdAndObjectId(currentCulture.Id, (int)classId, (int)objectId, @params), this.GetGridColumns((int)classId), objectId == null ? serializedObjectRepository.FilteredByCultureIdAndClassId( currentCulture.Id, (int)classId, @params ).ToList().Select(so => new ObjectViewModelFactory(this.RequestHandler).Create(so.ObjectId)) : serializedObjectRepository.FilteredByCultureIdAndClassIdAndObjectId( currentCulture.Id, (int)classId, (int)objectId, @params ).ToList().Select(so => new ObjectViewModelFactory(this.RequestHandler).Create(so.ObjectId)), "_Object" ) }); }