Exemplo n.º 1
0
        public ApiAdapter(IDataBaseManagerFactory dbEngine, string address, string port, string table, string login, string password)
        {
            DbManager   = new DatabaseManager(dbEngine, address, port, table, login, password);
            DbConnector = new DbConnector(DbManager);

            LanguageAdapter                = new LanguageAdapter(DbConnector);
            UserAdapter                    = new UserAdapter(DbConnector);
            UserDetailsAdapter             = new UserDetailsAdapter(DbConnector);
            TransactionTypeAdapter         = new TransactionTypeAdapter(DbConnector);
            TransferTypeAdapter            = new TransferTypeAdapter(DbConnector);
            FrequencyAdapter               = new FrequencyAdapter(DbConnector);
            ImportanceAdapter              = new ImportanceAdapter(DbConnector);
            TagAdapter                     = new TagAdapter(DbConnector);
            OperationAdapter               = new OperationAdapter(DbConnector);
            OperationDetailsAdapter        = new OperationDetailsAdapter(DbConnector);
            OperationTagRelationAdapter    = new OperationTagAdapter(DbConnector);
            OperationsGroupAdapter         = new OperationsGroupAdapter(DbConnector);
            OperationsGroupRelationAdapter = new OperationsGroupTagAdapter(DbConnector);
            FilterAdapter                  = new FilterAdapter(DbConnector);
            DashboardAdapter               = new DashboardAdapter(DbConnector);
            DashboardFilterRelationAdapter = new DashboardFilterRelationAdapter(DbConnector);
            BankAdapter                    = new BankAdapter(DbConnector);
            SettingsAdapter                = new SettingsAdapter(DbConnector);
            SchematicTypeAdapter           = new SchematicTypeAdapter(DbConnector);
            SchematicAdapter               = new SchematicAdapter(DbConnector);

            LanguageMapper        = new LanguageMapper();
            UserMapper            = new UserMapper();
            UserDetailsMapper     = new UserDetailsMapper();
            TransactionTypeMapper = new TransactionTypeMapper();
            TransferTypeMapper    = new TransferTypeMapper();
            FrequencyMapper       = new FrequencyMapper();
            ImportanceMapper      = new ImportanceMapper();
            TagMapper             = new TagMapper();
            TagRelationMapper     = new RelationTagMapper();
            OperationMapper       = new OperationMapper();
            OperationsGroupMapper = new OperationsGroupMapper();
            FilterMapper          = new FilterMapper();
            DashboardMapper       = new DashboardMapper();
            DashboardFilterMapper = new DashboardFilterMapper();
            BankMapper            = new BankMapper();
            SettingsMapper        = new SettingsMapper();
            SchematicTypeMapper   = new SchematicTypeMapper();
            SchematicMapper       = new SchematicMapper();
        }
Exemplo n.º 2
0
        public List <ApiOperation> GetOperations(ApiUser user, List <ApiTransactionType> transactionTypes, List <ApiTransferType> transferTypes, List <ApiFrequency> frequencies, List <ApiImportance> importances, List <ApiTag> tags)
        {
            var operations = OperationAdapter.GetAll($"user_id={user.Id}");
            var filter     = "";

            foreach (var operation in operations)
            {
                filter += $"operation_id={operation.Id} OR ";
            }
            if (filter.Length > 4)
            {
                filter = filter.Substring(0, filter.Length - 4);
            }

            var relations = OperationTagRelationAdapter.GetAll(filter).ToList();
            var details   = OperationDetailsAdapter.GetAll(filter).ToList();

            OperationMapper.Update(importances, frequencies, transactionTypes, transferTypes, tags, user, relations, details);

            return(OperationMapper.ConvertToApiEntitiesCollection(operations).ToList());
        }
Exemplo n.º 3
0
        public static void SetService()
        {
            Settings = new Settings2();

            var dataBaseData = ConfigurationManager.DataBaseData();

            DbManager   = new DatabaseManager(new MySqlConnectionFactory(), dataBaseData.Address, dataBaseData.Port, dataBaseData.Table, dataBaseData.Login, dataBaseData.Password);
            DbConnector = new DbConnector(DbManager);

            LanguageAdapter                = new LanguageAdapter(DbConnector);
            UserAdapter                    = new UserAdapter(DbConnector);
            UserDetailsAdapter             = new UserDetailsAdapter(DbConnector);
            TransactionTypeAdapter         = new TransactionTypeAdapter(DbConnector);
            TransferTypeAdapter            = new TransferTypeAdapter(DbConnector);
            FrequencyAdapter               = new FrequencyAdapter(DbConnector);
            ImportanceAdapter              = new ImportanceAdapter(DbConnector);
            TagAdapter                     = new TagAdapter(DbConnector);
            OperationAdapter               = new OperationAdapter(DbConnector);
            OperationDetailsAdapter        = new OperationDetailsAdapter(DbConnector);
            OperationTagRelationAdapter    = new OperationTagAdapter(DbConnector);
            OperationsGroupAdapter         = new OperationsGroupAdapter(DbConnector);
            OperationsGroupRelationAdapter = new OperationsGroupTagAdapter(DbConnector);

            LanguageMapper                = new LanguageMapper();
            UserMapper                    = new UserMapper();
            UserDetailsMapper             = new UserDetailsMapper();
            TransactionTypeMapper         = new TransactionTypeMapper();
            TransferTypeMapper            = new TransferTypeMapper();
            FrequencyMapper               = new FrequencyMapper();
            ImportanceMapper              = new ImportanceMapper();
            TagMapper                     = new TagMapper();
            OperationMapper               = new OperationMapper();
            OperationDetailsMapper        = new OperationDetailsMapper();
            RelationMapper                = new RelationMapper();
            OperationsGroupMapper         = new OperationsGroupMapper();
            OperationsGroupRelationMapper = new OperationsGroupRelationMapper();

            SetMainConfigurations();
        }
Exemplo n.º 4
0
        public static void LoadOperations()
        {
            OperationMapper.Update(User, OperationsGroups, Importances, Frequencies, TransactionTypes, TransferTypes);
            Operations = OperationMapper.ConvertToBusinessLogicEntitiesCollection(OperationAdapter.GetAll($"user_id={User.Id}")).ToList();

            if (Operations.Count > 0)
            {
                var filter = "";
                foreach (var operation in Operations)
                {
                    filter += $"operation_id={operation.Id} OR ";
                }
                filter = filter.Substring(0, filter.Length - 4);

                RelationMapper.Update(Operations, Tags);
                var relations     = RelationMapper.ConvertToBusinessLogicEntitiesCollection(OperationTagRelationAdapter.GetAll(filter));
                var relTags       = relations.Item1;
                var relOperations = relations.Item2;

                foreach (var operation in Operations)
                {
                    operation.SetDetailsList(OperationDetailsMapper.ConvertToBusinessLogicEntitiesCollection(OperationDetailsAdapter.GetAll($"operation_id={operation.Id}")));
                    operation.SetTags(relTags.Where(r => r.RelatedId == operation.Id));
                }

                foreach (var tag in Tags)
                {
                    tag.SetOperations(relOperations.Where(r => r.TagId == tag.Id));
                }
            }
        }