public GetBookByTitleQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(BookWithPagesConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            BookQueryRepository.Register(context);

            PageQueryRepository.Register(context);

            GetAllPagesLinkedAggregateQueryOperation = new GetAllLinkedAggregateQueryCollectionOperation <int, Page, PageOutputDto>
            {
                GetAllLinkedEntities      = (repository, entity, user) => ((PageQueryRepository)repository).GetAllPagesForBook(RootEntity.Id).ToList(),
                GetAllLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((PageQueryRepository)repository).GetAllPagesForBookAsync(RootEntity.Id);

                    return(entities.ToList());
                },
                CreateLinkedQueryAggregate = entity =>
                {
                    if (entity is Page)
                    {
                        return(new GetPageByIdQueryAggregate());
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            };

            QueryOperations.Enqueue(GetAllPagesLinkedAggregateQueryOperation);
        }
Beispiel #2
0
        public EmployeePersonQueryAggregate(RepositoryContext context) : base(context, null)
        {
            PersonLoadOperation = new GetEntityQueryOperation <PersonEntity>();

            QueryOperations.Enqueue(
                PersonLoadOperation
                );
        }
        public PersonSpouseQueryAggregate(DataAccess.RepositoryContext context) : base(context, null)
        {
            GetSpouseLoadOperation = new GetSingleLinkedEntityQueryOperation <PersonEntity2>
            {
                GetLinkedEntity = (repository, entity, user) =>
                                  ((PersonQueryRepository2)repository).GetForPerson(RootEntity.Id),

                GetLinkedEntityAsync = async(repository, entity, user) =>
                                       await((PersonQueryRepository2)repository).GetForPersonAsync(RootEntity.Id)
            };

            QueryOperations.Enqueue(
                GetSpouseLoadOperation
                );
        }
        public GetUserByNormalizedEmailQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(AuthorizationConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            UserQueryRepository.Register(context);

            RoleQueryRepository.Register(context);

            User_UserLogins_QueryRepository.Register(context);

            GetUserLoginsOperation = new GetCollectionLinkedValueObjectQueryOperation <User, UserLogin, User_UserLogins_QueryRepository.RepositoryKey>
            {
                GetLinkedValueObjects      = (repository, entity, user) => ((User_UserLogins_QueryRepository)repository).GetAll(RootEntity.Id).ToList(),
                GetLinkedValueObjectsAsync = async(repository, entity, user) =>
                {
                    var items = await((User_UserLogins_QueryRepository)repository).GetAllAsync(RootEntity.Id);

                    return(items.ToList());
                }
            };

            QueryOperations.Enqueue(GetUserLoginsOperation);

            GetAllRolesLinkedAggregateQueryOperation = new GetAllLinkedAggregateQueryCollectionOperation <int, Role, RoleOutputDto>
            {
                GetAllLinkedEntities      = (repository, entity, user) => ((RoleQueryRepository)repository).GetAllRolesForUser(RootEntity.Id).ToList(),
                GetAllLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((RoleQueryRepository)repository).GetAllRolesForUserAsync(RootEntity.Id);

                    return(entities.ToList());
                },
                CreateLinkedQueryAggregate = entity =>
                {
                    if (entity is Role)
                    {
                        return(new GetRoleByIdQueryAggregate());
                    }
                    else
                    {
                        throw new InvalidOperationException();
                    }
                }
            };

            QueryOperations.Enqueue(GetAllRolesLinkedAggregateQueryOperation);
        }
Beispiel #5
0
        public ManagerEmployeesQueryAggregate(DataAccess.RepositoryContext context) : base(context, null)
        {
            GetEmployeesLoadOperation = new GetCollectionLinkedEntityQueryOperation <PersonEntity3>
            {
                //GetLinkedEntities = (repository, entity, user) =>
                //    ((PersonQueryRepository4)repository).GetForManager(RootEntity.Id, user).ToList(),

                GetLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((PersonQueryRepository4)repository).GetForManagerAsync(RootEntity.Id);

                    return(entities.ToList());
                }
            };

            QueryOperations.Enqueue(
                GetEmployeesLoadOperation
                );
        }
        public BookPagesQueryAggregate(RepositoryContext context) : base(context, null)
        {
            GetPagesLoadOperation = new GetCollectionLinkedEntityQueryOperation <PageEntity>
            {
                GetLinkedEntities = (repository, entity, user) =>
                                    ((PageQueryRepository)repository).GetForBook(RootEntity.Id).ToList(),

                GetLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((PageQueryRepository)repository).GetForBookAsync(RootEntity.Id);

                    return(entities.ToList());
                }
            };

            QueryOperations.Enqueue(
                GetPagesLoadOperation
                );
        }
Beispiel #7
0
        public ClassEnrollmentQueryAggregate(RepositoryContext context) : base(context, null)
        {
            GetStudentsLoadOperation = new GetCollectionLinkedEntityQueryOperation <StudentEntity>
            {
                GetLinkedEntities = (repository, entity, user) =>
                                    ((StudentQueryRepository)repository).GetForClass(RootEntity.Id).ToList(),

                GetLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((StudentQueryRepository)repository).GetForClassAsync(RootEntity.Id);

                    return(entities.ToList());
                }
            };

            QueryOperations.Enqueue(
                GetStudentsLoadOperation
                );
        }
Beispiel #8
0
        public PersonFriendsQueryAggregate(RepositoryContext context) : base(context, null)
        {
            GetFriendsLoadOperation = new GetCollectionLinkedEntityQueryOperation <PersonEntity>
            {
                GetLinkedEntities = (repository, entity, user) =>
                                    ((PersonQueryRepository3)repository).GetForPerson(RootEntity.Id).ToList(),

                GetLinkedEntitiesAsync = async(repository, entity, user) =>
                {
                    var entities = await((PersonQueryRepository3)repository).GetForPersonAsync(RootEntity.Id);

                    return(entities.ToList());
                }
            };

            QueryOperations.Enqueue(
                GetFriendsLoadOperation
                );
        }
Beispiel #9
0
        public GetUserByNormalizedEmailQueryAggregate() : base(new DomainFramework.DataAccess.RepositoryContext(UserWithUserLoginsConnectionClass.GetConnectionName()))
        {
            var context = (DomainFramework.DataAccess.RepositoryContext)RepositoryContext;

            UserQueryRepository.Register(context);

            User_UserLogins_QueryRepository.Register(context);

            GetUserLoginsOperation = new GetCollectionLinkedValueObjectQueryOperation <User, UserLogin, User_UserLogins_QueryRepository.RepositoryKey>
            {
                GetLinkedValueObjects      = (repository, entity, user) => ((User_UserLogins_QueryRepository)repository).GetAll(RootEntity.Id).ToList(),
                GetLinkedValueObjectsAsync = async(repository, entity, user) =>
                {
                    var items = await((User_UserLogins_QueryRepository)repository).GetAllAsync(RootEntity.Id);

                    return(items.ToList());
                }
            };

            QueryOperations.Enqueue(GetUserLoginsOperation);
        }
        public CountryCapitalCityQueryAggregate() : base(null, null)
        {
            RepositoryContext = new DataAccess.RepositoryContext("SqlServerTest.DomainFrameworkOneToOneTest.ConnectionString");

            RepositoryContext.RegisterQueryRepository <CountryEntity>(new CountryQueryRepository());

            RepositoryContext.RegisterQueryRepository <CapitalCityEntity>(new CapitalCityQueryRepository());

            GetCapitalCityLoadOperation = new GetSingleLinkedEntityQueryOperation <CapitalCityEntity>
            {
                GetLinkedEntity = (repository, entity, user) =>
                                  ((CapitalCityQueryRepository)repository).GetForCountry(RootEntity.Id),

                GetLinkedEntityAsync = async(repository, entity, user) =>
                                       await((CapitalCityQueryRepository)repository).GetForCountryAsync(RootEntity.Id)
            };

            QueryOperations.Enqueue(
                GetCapitalCityLoadOperation
                );
        }
Beispiel #11
0
 public QueryOperation(string field, QueryOperations operation, object value)
 {
     this.field = field;
     this.operation = operation;
     this.value = value;
 }
Beispiel #12
0
 private static string OperationToString(QueryOperations operation)
 {
     switch (operation)
     {
         case QueryOperations.Addition:
             return "+";
         case QueryOperations.Subtraction:
             return "-";
         case QueryOperations.Multiplication:
             return "*";
         case QueryOperations.Division:
             return "/";
         case QueryOperations.BinaryAnd:
             return "&";
         case QueryOperations.BinaryOr:
             return "|";
     }
     return "!";
 }
Beispiel #13
0
        /**
         * <h3> Get Records </h3>
         * This method is used to get records from the module through a COQL query.
         * @throws Exception
         */
        public static void GetRecords()
        {
            //Get instance of QueryOperations Class
            QueryOperations queryOperations = new QueryOperations();

            //Get instance of BodyWrapper Class that will contain the request body
            BodyWrapper bodyWrapper = new BodyWrapper();

            string selectQuery = "select Last_Name from Leads where Last_Name is not null limit 200";

            bodyWrapper.SelectQuery = selectQuery;

            //Call getRecords method that takes BodyWrapper instance as parameter
            APIResponse <ResponseHandler> response = queryOperations.GetRecords(bodyWrapper);

            if (response != null)
            {
                //Get the status code from response
                Console.WriteLine("Status Code: " + response.StatusCode);

                //Check if expected response is received
                if (response.IsExpected)
                {
                    //Get the object from response
                    ResponseHandler responseHandler = response.Object;

                    if (responseHandler is ResponseWrapper)
                    {
                        //Get the received ResponseWrapper instance
                        ResponseWrapper responseWrapper = (ResponseWrapper)responseHandler;

                        //Get the obtained Record instances
                        List <API.Record.Record> records = responseWrapper.Data;

                        foreach (API.Record.Record record in records)
                        {
                            //Get the ID of each Record
                            Console.WriteLine("Record ID: " + record.Id);

                            //Get the createdBy User instance of each Record
                            API.Users.User createdBy = record.CreatedBy;

                            //Check if createdBy is not null
                            if (createdBy != null)
                            {
                                //Get the ID of the createdBy User
                                Console.WriteLine("Record Created By User-ID: " + createdBy.Id);

                                //Get the name of the createdBy User
                                Console.WriteLine("Record Created By User-Name: " + createdBy.Name);

                                //Get the Email of the createdBy User
                                Console.WriteLine("Record Created By User-Email: " + createdBy.Email);
                            }

                            //Get the CreatedTime of each Record
                            Console.WriteLine("Record CreatedTime: " + record.CreatedTime);

                            //Get the modifiedBy User instance of each Record
                            API.Users.User modifiedBy = record.ModifiedBy;

                            //Check if modifiedBy is not null
                            if (modifiedBy != null)
                            {
                                //Get the ID of the modifiedBy User
                                Console.WriteLine("Record Modified By User-ID: " + modifiedBy.Id);

                                //Get the name of the modifiedBy User
                                Console.WriteLine("Record Modified By User-Name: " + modifiedBy.Name);

                                //Get the Email of the modifiedBy User
                                Console.WriteLine("Record Modified By User-Email: " + modifiedBy.Email);
                            }

                            //Get the ModifiedTime of each Record
                            Console.WriteLine("Record ModifiedTime: " + record.ModifiedTime);

                            //To get particular field value
                            Console.WriteLine("Record Field Value: " + record.GetKeyValue("Last_Name"));                            // FieldApiName

                            Console.WriteLine("Record KeyValues: ");

                            //Get the KeyValue map
                            foreach (KeyValuePair <string, object> entry in record.GetKeyValues())
                            {
                                string keyName = entry.Key;

                                object value = entry.Value;

                                if (value is IList)
                                {
                                    Console.WriteLine("Record KeyName : " + keyName);

                                    IList dataList = (IList)value;

                                    foreach (object data in dataList)
                                    {
                                        if (data is IDictionary)
                                        {
                                            Console.WriteLine("Record KeyName : " + keyName + " - Value : ");

                                            foreach (KeyValuePair <string, object> entry1 in (Dictionary <string, object>)data)
                                            {
                                                Console.WriteLine(entry1.Key + " : " + JsonConvert.SerializeObject(entry1.Value));
                                            }
                                        }
                                        else
                                        {
                                            Console.WriteLine(JsonConvert.SerializeObject(data));
                                        }
                                    }
                                }
                                else if (value is IDictionary)
                                {
                                    Console.WriteLine("Record KeyName : " + keyName + " - Value : ");

                                    foreach (KeyValuePair <string, object> entry1 in (Dictionary <string, object>)value)
                                    {
                                        Console.WriteLine(entry1.Key + " : " + JsonConvert.SerializeObject(entry1.Value));
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("Record KeyName : " + keyName + " - Value : " + JsonConvert.SerializeObject(value));
                                }
                            }
                        }

                        //Get the Object obtained Info instance
                        API.Record.Info info = responseWrapper.Info;

                        //Check if info is not null
                        if (info != null)
                        {
                            if (info.Count != null)
                            {
                                //Get the Count of the Info
                                Console.WriteLine("Record Info Count: " + info.Count.ToString());
                            }

                            if (info.MoreRecords != null)
                            {
                                //Get the MoreRecords of the Info
                                Console.WriteLine("Record Info MoreRecords: " + info.MoreRecords.ToString());
                            }
                        }
                    }
                    //Check if the request returned an exception
                    else if (responseHandler is APIException)
                    {
                        //Get the received APIException instance
                        APIException exception = (APIException)responseHandler;

                        //Get the Status
                        Console.WriteLine("Status: " + exception.Status.Value);

                        //Get the Code
                        Console.WriteLine("Code: " + exception.Code.Value);

                        Console.WriteLine("Details: ");

                        //Get the details map
                        foreach (KeyValuePair <string, object> entry in exception.Details)
                        {
                            //Get each value in the map
                            Console.WriteLine(entry.Key + " : " + entry.Value);
                        }

                        //Get the Message
                        Console.WriteLine("Message: " + exception.Message.Value);
                    }
                }
                else
                {                //If response is not as expected
                    //Get model object from response
                    Model responseObject = response.Model;

                    //Get the response object's class
                    Type type = responseObject.GetType();

                    //Get all declared fields of the response class
                    Console.WriteLine("Type is: {0}", type.Name);

                    PropertyInfo[] props = type.GetProperties();

                    Console.WriteLine("Properties (N = {0}):", props.Length);

                    foreach (var prop in props)
                    {
                        if (prop.GetIndexParameters().Length == 0)
                        {
                            Console.WriteLine("{0} ({1}) : {2}", prop.Name, prop.PropertyType.Name, prop.GetValue(responseObject));
                        }
                        else
                        {
                            Console.WriteLine("{0} ({1}) : <Indexed>", prop.Name, prop.PropertyType.Name);
                        }
                    }
                }
            }
        }