Ejemplo n.º 1
0
        public static void AddPaging(
            this IHeaderDictionary header,
            CollectionQueryParameters queryParameters,
            int totalCount,
            int maxPages = 500)
        {
            var skip = queryParameters.Skip ?? 0;

            var pageSize = queryParameters.Top ?? maxPages;

            int currentPage = (skip / pageSize) + 1;

            int totalPages = totalCount > 0
                ? (int)Math.Ceiling(totalCount / (double)pageSize)
                : 0;

            var paginationHeader = new
            {
                currentPage,
                pageSize,
                totalCount,
                totalPages
            };

            header.Add("X-Pagination", JsonConvert.SerializeObject(paginationHeader));
        }
Ejemplo n.º 2
0
        public async Task <(int, IEnumerable <StudentOutputDto>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var repository = (StudentQueryRepository)RepositoryContext.GetQueryRepository(typeof(Student));

            var(count, entities) = await repository.GetNotEnrolledAsync(queryParameters);

            var data = new Tuple <int, IEnumerable <IEntity> >(count, entities);

            return(await GetAsync(data));
        }
        public (int, IEnumerable <ApplicationLogOutputDto>) Get(CollectionQueryParameters queryParameters)
        {
            var repository = (ApplicationLogQueryRepository)RepositoryContext.GetQueryRepository(typeof(ApplicationLog));

            var(count, entities) = repository.Get(queryParameters);

            var data = new Tuple <int, IEnumerable <IEntity> >(count, entities);

            return(Get(data));
        }
        public override async Task <(int, IEnumerable <PersonEntity3>)> GetAsync(CollectionQueryParameters parameters)
        {
            var result = await Query <PersonEntity3>
                         .Collection()
                         .Connection(ConnectionName)
                         .StoredProcedure("p_Person_GetAll")
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 5
0
        public (int, IEnumerable <StudentOutputDto>) Get(CollectionQueryParameters queryParameters)
        {
            var repository = (StudentQueryRepository)RepositoryContext.GetQueryRepository(typeof(Student));

            var(count, entities) = repository.GetNotEnrolled(queryParameters);

            var data = new Tuple <int, IEnumerable <IEntity> >(count, entities);

            return(Get(data));
        }
Ejemplo n.º 6
0
        public CollectionQueryParameters Build()
        {
            var queryParameters = new CollectionQueryParameters();

            foreach (var query in _queryCollection)
            {
                var value = query.Value.SingleOrDefault();

                switch (query.Key.ToLowerInvariant())
                {
                case "$top":
                {
                    queryParameters.Top = int.Parse(value);
                }
                break;

                case "$skip":
                {
                    queryParameters.Skip = int.Parse(value);
                }
                break;

                case "$select":
                {
                    queryParameters.Select = value
                                             .Split(',', StringSplitOptions.RemoveEmptyEntries)
                                             .Select(f => f.Trim());
                }
                break;

                case "$filter":
                {
                    queryParameters.Filter = new ODataFilterBuilder()
                                             .Build(value);
                }
                break;

                case "$orderby":
                {
                    queryParameters.OrderBy = new ODataOrderByBuilder()
                                              .Build(value);
                }
                break;

                default:
                {
                    queryParameters.ExtraParameters.Add(query.Key, value);
                }
                break;
                }
            }

            return(queryParameters);
        }
Ejemplo n.º 7
0
        public override (int, IEnumerable <Page>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Page>
                         .Collection()
                         .Connection(BookWithPagesConnectionClass.GetConnectionName())
                         .StoredProcedure("[BookBoundedContext].[pPage_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
        public override (int, IEnumerable <SimpleLog>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <SimpleLog>
                         .Collection()
                         .Connection(SimpleLogsConnectionClass.GetConnectionName())
                         .StoredProcedure("[SimpleLogsBoundedContext].[pSimpleLog_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 9
0
        public async Task <(int, IEnumerable <Student>)> GetNotEnrolledAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Student>
                         .Collection()
                         .Connection(ClassesWithStudentsConnectionClass.GetConnectionName())
                         .StoredProcedure("[ClassBoundedContext].[Student_GetNotEnrolled]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 10
0
        public override (int, IEnumerable <Truck>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Truck>
                         .Collection()
                         .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pTruck_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 11
0
        public async override Task <(int, IEnumerable <Course>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Course>
                         .Collection()
                         .Connection(CourseWithPreRequisitesAndRelatedConnectionClass.GetConnectionName())
                         .StoredProcedure("[CourseBoundedContext].[pCourse_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 12
0
        public async override Task <(int, IEnumerable <Employee>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Employee>
                         .Collection()
                         .Connection(EmployeeWithSpouseConnectionClass.GetConnectionName())
                         .StoredProcedure("[EmployeeBoundedContext].[pEmployee_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 13
0
        public override (int, IEnumerable <Address>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Address>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pAddress_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 14
0
        public async override Task <(int, IEnumerable <Book>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Book>
                         .Collection()
                         .Connection(BookWithPagesConnectionClass.GetConnectionName())
                         .StoredProcedure("[BookBoundedContext].[pBook_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 15
0
        public async override Task <(int, IEnumerable <Country>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Country>
                         .Collection()
                         .Connection(CountryWithCapitalCityConnectionClass.GetConnectionName())
                         .StoredProcedure("[CountryBoundedContext].[pCountry_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 16
0
        public override (int, IEnumerable <Executive>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Executive>
                         .Collection()
                         .Connection(ExecutiveEmployeePersonConnectionClass.GetConnectionName())
                         .StoredProcedure("[ExecutiveBoundedContext].[pExecutive_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
        public override (int, IEnumerable <Organization>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Organization>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pOrganization_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 18
0
        public override (int, IEnumerable <Manager>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Manager>
                         .Collection()
                         .Connection(ManagerWithEmployeesConnectionClass.GetConnectionName())
                         .StoredProcedure("[ManagerBoundedContext].[pManager_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 19
0
        public async override Task <(int, IEnumerable <Car>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Car>
                         .Collection()
                         .Connection(MechanicServicesSeveralVehiclesConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pCar_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 20
0
        public override (int, IEnumerable <Person>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <Person>
                         .Collection()
                         .Connection(PersonWithSpouseAndDependantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[PersonBoundedContext].[pPerson_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 21
0
        public async override Task <(int, IEnumerable <TestEntity>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <TestEntity>
                         .Collection()
                         .Connection(EntityWithMultiValuedValueObjectConnectionClass.GetConnectionName())
                         .StoredProcedure("[pTestEntity_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
        public async override Task <(int, IEnumerable <TestEntity>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <TestEntity>
                         .Collection()
                         .Connection(SimpleEntityWithAutoGeneratedKeyConnectionClass.GetConnectionName())
                         .StoredProcedure("[SimpleEntityWithAutoGeneratedKeyBoundedContext].[pTestEntity_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
        public async override Task <(int, IEnumerable <Address>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Address>
                         .Collection()
                         .Connection(OrganizationPersonWithCommonEntitiesConnectionClass.GetConnectionName())
                         .StoredProcedure("[OrganizationPersonBoundedContext].[pAddress_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
        public async override Task <(int, IEnumerable <Organization>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Organization>
                         .Collection()
                         .Connection(SchoolRoleOrganizationAddressConnectionClass.GetConnectionName())
                         .StoredProcedure("[SchoolBoundedContext].[pOrganization_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 25
0
        public async override Task <(int, IEnumerable <Person>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Person>
                         .Collection()
                         .Connection(PersonWithDisciplesAndServantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[PersonBoundedContext].[pPerson_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            return(result.Count, result.Records);
        }
Ejemplo n.º 26
0
        public async override Task <(int, IEnumerable <Class>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <Class>
                         .Collection()
                         .Connection(ClassesWithStudentsConnectionClass.GetConnectionName())
                         .StoredProcedure("[ClassBoundedContext].[pClass_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .ExecuteAsync();

            var count = (int)result.GetParameter("count").Value;

            return(count, result.Records);
        }
Ejemplo n.º 27
0
        public async override Task <(int, IEnumerable <ApplicationLog>)> GetAsync(CollectionQueryParameters queryParameters)
        {
            var result = await Query <ApplicationLog>
                         .Collection()
                         .Connection(ApplicationLogsConnectionClass.GetConnectionName())
                         .StoredProcedure("[Logs].[pApplicationLog_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Size(20).Output())
                         .ExecuteAsync();

            var count = (string)result.GetParameter("count").Value;

            return(int.Parse(count), result.Data);
        }
Ejemplo n.º 28
0
        public override (int, IEnumerable <User>) Get(CollectionQueryParameters queryParameters)
        {
            var result = Query <User>
                         .Collection()
                         .Connection(AuthorizationConnectionClass.GetConnectionName())
                         .StoredProcedure("[AccessControl].[pUser_Get]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Size(20).Output())
                         .Execute();

            var count = (string)result.GetParameter("count").Value;

            return(int.Parse(count), result.Data);
        }
        public override (int, IEnumerable <Inspection>) Get(int truckId, CollectionQueryParameters queryParameters)
        {
            var result = Query <Inspection>
                         .Collection()
                         .Connection(MechanicServicesSingleVehicleConnectionClass.GetConnectionName())
                         .StoredProcedure("[GarageBoundedContext].[pTruck_GetInspections]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Parameters(
                p => p.Name("truckId").Value(truckId)
                )
                         .Execute();

            return(result.Count, result.Records);
        }
Ejemplo n.º 30
0
        public (int, IEnumerable <Person>) GetServantsForPerson(int personId, CollectionQueryParameters queryParameters)
        {
            var result = Query <Person>
                         .Collection()
                         .Connection(PersonWithDisciplesAndServantsConnectionClass.GetConnectionName())
                         .StoredProcedure("[PersonBoundedContext].[pPerson_GetServants]")
                         .QueryParameters(queryParameters)
                         .Parameters(p => p.Name("count").Count())
                         .Parameters(
                p => p.Name("personId").Value(personId)
                )
                         .Execute();

            return(result.Count, result.Records);
        }