Exemplo n.º 1
0
        public virtual async Task <IActionResult> GetAll(
            [FromQuery] int page           = 1,
            [FromQuery] string searchQuery = null,
            [FromQuery] string orderBy     = null,
            [FromQuery] string orderType   = null)
        {
            PaginatedList <TEntityViewModel> entitiesResult = await this.GetAllEntitiesPaginatedAsync(
                page,
                searchQuery,
                this.InterceptOrderProperty(orderBy),
                orderType);

            TableViewViewModel model = new TableViewViewModel();

            model.SingleEntityName = StringFunctions.SplitWordsByCapitalLetters(typeof(TEntity).Name);
            model.Title            = model.SingleEntityName.ToPluralString();
            this.ViewData[BreadcrumbPageTitlePlaceholder] = model.Title;

            model.Table = EntityTableMapper.Map(entitiesResult, this.BuildTableViewActions()?.ToArray());
            model.Table.SetPaginationRedirection(this.AreaName, this.ControllerName, this.ActionName);
            this.ViewData.Add("SearchQuery", searchQuery);
            this.ViewData.Add("OrderProperties", this.GetOrderProperties());
            this.ViewData.Add("OrderBy", orderBy);
            this.ViewData.Add("OrderType", orderType);

            this.InitializeNavigationActions(this.BuildTableViewNavigationActions());

            return(this.GetAllView(model));
        }
        public void GetDdlTest4()
        {
            var dbVm  = new DbViewModel();
            var table = new TableViewViewModel("SNOW_LINE", "SELECT CITY, STATE, ALTITUDE FROM CITIES WHERE ALTITUDE > 5000");

            dbVm.Tables.Add(table);

            var col1 = new ColumInfo("CITY", new FieldType(8, null, null, null, null), new ConstraintsInfo(ConstraintsKind.Primary), "SARARY", false);

            table.Colums.Add(new ColumViewMoodel(col1));
            var col2 = new ColumInfo("STATE", new FieldType(37, null, 100, null, null), new ConstraintsInfo(ConstraintsKind.Primary), "NAME", false);

            table.Colums.Add(new ColumViewMoodel(col2));
            var col3 = new ColumInfo("SNOW_ALTITUDE", new FieldType(35, null, null, null, null), new ConstraintsInfo(ConstraintsKind.None), "RDB$3", false);

            table.Colums.Add(new ColumViewMoodel(col3));

            table.GetDdl(dbVm).Is(
                "CREATE VIEW SNOW_LINE (CITY, STATE, SNOW_ALTITUDE) AS" + Environment.NewLine +
                "SELECT CITY, STATE, ALTITUDE FROM CITIES WHERE ALTITUDE > 5000");
        }
        public async Task LoadDatabase(DatabaseInfo dbInf)
        {
            _dbInfo = dbInf;
            var table = new List<ITableViewModel>();
            await Task.Run(() =>
             {
                 using (var con = new FbConnection(_dbInfo.ConnectionString))
                 {
                     con.Open();
                     foreach (var item in _dbInfo.GetTables(con))
                     {
                         var vm = new TableViewModel(item.TableName);
                         foreach (var colums in item.GetColums(con))
                         {
                             vm.Colums.Add(new ColumViewMoodel(colums));
                         }
                         foreach (var trigger in item.GetTrigger(con))
                         {
                             vm.Triggers.Add(new TriggerViewModel(trigger));
                         }
                         foreach (var idx in item.GetIndex(con))
                         {
                             vm.Indexs.Add(new IndexViewModel(idx));
                         }
                         table.Add(vm);
                     }

                     foreach (var item in _dbInfo.GetViews(con))
                     {
                         var vm = new TableViewViewModel(item.ViewName, item.Source);
                         foreach (var colums in item.GetColums(con))
                         {
                             vm.Colums.Add(new ColumViewMoodel(colums));
                         }
                         table.Add(vm);
                     }
                 }
             });
            Tables = table;
            AdditionalInfo = new AdditionalDbInfoControl(this);
            RaisePropertyChanged(nameof(Tables));
            RaisePropertyChanged(nameof(AdditionalInfo));
        }
        public void GetDdlTest4()
        {
            var dbVm = new DbViewModel();
            var table = new TableViewViewModel("SNOW_LINE", "SELECT CITY, STATE, ALTITUDE FROM CITIES WHERE ALTITUDE > 5000");
            dbVm.Tables.Add(table);

            var col1 = new ColumInfo("CITY", new FieldType(8, null, null, null, null, 4), new ColumConstraintsInfo(ConstraintsKind.Primary), "SARARY", false, true, "");
            table.Colums.Add(new ColumViewMoodel(col1));
            var col2 = new ColumInfo("STATE", new FieldType(37, null, 100, null, null, 400), new ColumConstraintsInfo(ConstraintsKind.Primary), "NAME", false, true, "");
            table.Colums.Add(new ColumViewMoodel(col2));
            var col3 = new ColumInfo("SNOW_ALTITUDE", new FieldType(35, null, null, null, null, 8), new ColumConstraintsInfo(ConstraintsKind.None), "RDB$3", false, true, "");
            table.Colums.Add(new ColumViewMoodel(col3));

            table.GetDdl(dbVm).Is(
            "CREATE VIEW SNOW_LINE (CITY, STATE, SNOW_ALTITUDE) AS" + Environment.NewLine +
            "SELECT CITY, STATE, ALTITUDE FROM CITIES WHERE ALTITUDE > 5000");
        }
Exemplo n.º 5
0
 /// <summary>
 /// Build action result to table view.
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 protected virtual IActionResult GetAllView(TableViewViewModel model)
 {
     return(this.View("EntityViews/GetAll", model));
 }