Ejemplo n.º 1
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            var rowDest = new FrameworkConfigGrid();

            Data.RowCopy(args.Row, rowDest);
            rowDest.IsExist = true;
            await Data.InsertAsync(rowDest);

            var rowReload = await Reload(args.Row);

            Data.RowCopy(rowReload, args.Row);

            result.IsHandled = true;
        }
Ejemplo n.º 2
0
        protected override async Task UpdateAsync(UpdateArgs args, UpdateResult result)
        {
            // ConfigGrid
            if (args.Row.ConfigGridId == null)
            {
                var rowDisplayReload = await Reload(args.RowOld); // ConfigGrid row might have been added in the meantime, if multiple ConfigField rows are in the grid.

                args.Row.ConfigGridId = rowDisplayReload.ConfigGridId;
                if (args.Row.ConfigGridId == null)
                {
                    var rowDest = new FrameworkConfigGrid();
                    Data.RowCopy(args.Row, rowDest, "ConfigGrid");
                    rowDest.IsDelete = false;
                    await Data.InsertAsync(rowDest);

                    args.Row.ConfigGridId = rowDest.Id;
                }
            }

            // ConfigField
            if (args.Row.ConfigFieldId == null)
            {
                var rowDest = new FrameworkConfigField();
                Data.RowCopy(args.Row, rowDest, "ConfigField");
                rowDest.ConfigGridId = args.Row.ConfigGridId.Value;
                rowDest.FieldId      = args.Row.FieldId;
                rowDest.IsDelete     = false;
                await Data.InsertAsync(rowDest);

                args.Row.ConfigFieldId = rowDest.Id;
            }
            else
            {
                var rowDest = new FrameworkConfigField();
                Data.RowCopy(args.Row, rowDest, "ConfigField");
                await Data.UpdateAsync(rowDest);
            }

            // Reload
            {
                var rowDisplayReload = await Reload(args.Row);

                Data.RowCopy(rowDisplayReload, args.Row);
            }

            result.IsHandled = true;
        }
Ejemplo n.º 3
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            var rowDest = new FrameworkConfigGrid();

            Data.RowCopy(args.Row, rowDest);
            int tableId = (await Data.Query <FrameworkTable>().Where(item => item.TableNameCSharp == TableNameCSharp).QueryExecuteAsync()).Single().Id;

            rowDest.TableId  = tableId;
            rowDest.IsDelete = false;
            await Data.InsertAsync(rowDest);

            Data.RowCopy(rowDest, result.Row);
            var rowReload = await Reload(result.Row);

            Data.RowCopy(rowReload, result.Row);

            result.IsHandled = true;
        }
Ejemplo n.º 4
0
        protected override async Task InsertAsync(InsertArgs args, InsertResult result)
        {
            args.Row.ConfigGridTableId    = GridConfigGridRowSelect.TableId;    // Master
            args.Row.ConfigGridConfigName = GridConfigGridRowSelect.ConfigName; // Master

            var rowDest = new FrameworkConfigField();

            Data.RowCopy(args.Row, rowDest, "ConfigField");
            if (GridConfigGridRowSelect.Id == null) // Master does not have FrameworkConfigGrid in database
            {
                var rowDestConfigGrid = new FrameworkConfigGrid();
                Data.RowCopy(GridConfigGridRowSelect, rowDestConfigGrid);
                rowDestConfigGrid.IsDelete = false;
                await Data.InsertAsync(rowDestConfigGrid);

                GridConfigGridRowSelect.Id = rowDestConfigGrid.Id;
            }
            rowDest.ConfigGridId = GridConfigGridRowSelect.Id.Value; // Master

            // Lookup field
            string fieldNameCSharp = ((FrameworkConfigFieldDisplay)args.Row).FieldFieldNameCSharp; // Text entered by user.
            var    fieldList       = await Data.Query <FrameworkField>().Where(item => item.TableId == GridConfigGridRowSelect.TableId && item.FieldNameCSharp == fieldNameCSharp).QueryExecuteAsync();

            if (fieldList.Count == 0)
            {
                throw new Exception("Field not found!");
            }
            int fieldId = fieldList.Single().Id;

            rowDest.FieldId  = fieldId;
            args.Row.FieldId = fieldId;
            rowDest.IsDelete = false;
            await Data.InsertAsync(rowDest);

            var rowReload = await Reload(args.Row);

            Data.RowCopy(rowReload, args.Row);

            result.IsHandled = true;
        }
Ejemplo n.º 5
0
        protected override async Task UpdateAsync(UpdateArgs args, UpdateResult result)
        {
            // Insert
            bool isInsert = false;

            if (args.Row.Id == null)
            {
                var rowReload = await Reload(args.RowOld);

                args.Row.Id = rowReload.Id;
                if (args.Row.Id == null)
                {
                    var rowDest = new FrameworkConfigGrid();
                    Data.RowCopy(args.Row, rowDest);
                    rowDest.IsDelete = false;
                    await Data.InsertAsync(rowDest);

                    args.Row.Id = rowDest.Id;
                    isInsert    = true;
                }
            }

            // Update
            if (isInsert == false)
            {
                var rowDest = new FrameworkConfigGrid();
                Data.RowCopy(args.Row, rowDest);
                rowDest.IsDelete = false;
                await Data.UpdateAsync(rowDest);
            }

            // Reload
            {
                var rowDisplayReload = await Reload(args.Row);

                Data.RowCopy(rowDisplayReload, args.Row);
            }

            result.IsHandled = true;
        }