Example #1
0
        public List <ApiDashboard> GetDashboards(ApiUser user, List <ApiFilter> filters)
        {
            DashboardMapper.Update(user);
            var dashboards = DashboardMapper.ConvertToApiEntitiesCollection(DashboardAdapter.GetAll($"user_id={user.Id}")).ToList();
            var filter     = "";

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

            DashboardFilterMapper.Update(filters, dashboards);
            var tmp = DashboardFilterRelationAdapter.GetAll(filter).GroupBy(t => t.DashboardId);

            foreach (var group in tmp)
            {
                dashboards.Where(t => t.Id == group.Key).FirstOrDefault().UpdateRelations(DashboardFilterMapper.ConvertToApiEntitiesCollection(group));
            }

            return(dashboards.OrderBy(o => o.Order).ToList());
        }
Example #2
0
        private void DeleteDashboard(ApiDashboard dashboard)
        {
            var tmp = DashboardMapper.ConvertToDALEntity(dashboard);

            foreach (var relation in tmp.Relations)
            {
                DashboardFilterRelationAdapter.Delete(relation.Id);
            }
            DashboardAdapter.Delete(tmp.Dashboard.Id);
        }
Example #3
0
        private void InsertDashboard(ref ApiDashboard dashboard)
        {
            var tmp = DashboardMapper.ConvertToDALEntity(dashboard);

            var idx = DashboardAdapter.Insert(tmp.Dashboard);

            dashboard.UpdateId(idx);
            foreach (var relation in tmp.Relations)
            {
                relation.UpdateDashboardId(idx);
                DashboardFilterRelationAdapter.Insert(relation);
            }
        }
Example #4
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();
        }