Esempio n. 1
0
        public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null)
        {
            if (string.IsNullOrEmpty(Id))
            {
                Status = Status == default ? Enum.Parse <MixContentStatus>(MixService.GetConfig <string>
                                                                               (MixAppSettingKeywords.DefaultContentStatus)) : Status;
            }

            if (MixDatabaseColumnId > 0)
            {
                Field ??= MixDatabaseColumns.UpdateViewModel.Repository.GetSingleModel(
                    f => f.Id == MixDatabaseColumnId
                    , _context, _transaction).Data;
                if (Field != null && DataType == MixDataType.Reference)
                {
                    MixDatabaseName = _context.MixDatabase.FirstOrDefault(m => m.Id == Field.ReferenceId)?.Name;
                }
            }
            else // additional field for page / post / module => id = 0
            {
                Field = new MixDatabaseColumns.UpdateViewModel()
                {
                    DataType = DataType,
                    Title    = MixDatabaseColumnName,
                    Name     = MixDatabaseColumnName,
                    Priority = Priority
                };
            }

            if (string.IsNullOrEmpty(Id) && Field != null)
            {
                ParseDefaultValue(Field.DefaultValue);
            }
        }
Esempio n. 2
0
        private static string GenerateColumnSql(MixDatabaseColumns.UpdateViewModel col)
        {
            string colType  = GetColumnType(col.DataType, col.ColumnConfigurations.MaxLength);
            string nullable = col.IsRequire ? "NOT NUll" : "NULL";

            return($"{col.Name} {colType} {nullable}");
        }