public static JProperty ToJProperty(this MixAttributeSetValue item)
        {
            switch (item.DataType)
            {
            case MixEnums.MixDataType.DateTime:
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixEnums.MixDataType.Date:
                if (!item.DateTimeValue.HasValue)
                {
                    if (DateTime.TryParseExact(
                            item.StringValue,
                            "MM/dd/yyyy HH:mm:ss",
                            CultureInfo.InvariantCulture,
                            DateTimeStyles.RoundtripKind,
                            out DateTime date))
                    {
                        item.DateTimeValue = date;
                    }
                }
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixEnums.MixDataType.Time:
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixEnums.MixDataType.Double:
                return(new JProperty(item.AttributeFieldName, item.DoubleValue ?? 0));

            case MixEnums.MixDataType.Boolean:
                return(new JProperty(item.AttributeFieldName, item.BooleanValue));

            case MixEnums.MixDataType.Integer:
                return(new JProperty(item.AttributeFieldName, item.IntegerValue ?? 0));

            case MixEnums.MixDataType.Reference:
                //string url = $"/api/v1/odata/en-us/related-attribute-set-data/mobile/parent/set/{Id}/{item.Field.ReferenceId}";
                return(new JProperty(item.AttributeFieldName, null));

            case MixEnums.MixDataType.Custom:
            case MixEnums.MixDataType.Duration:
            case MixEnums.MixDataType.PhoneNumber:
            case MixEnums.MixDataType.Text:
            case MixEnums.MixDataType.Html:
            case MixEnums.MixDataType.MultilineText:
            case MixEnums.MixDataType.EmailAddress:
            case MixEnums.MixDataType.Password:
            case MixEnums.MixDataType.Url:
            case MixEnums.MixDataType.ImageUrl:
            case MixEnums.MixDataType.CreditCard:
            case MixEnums.MixDataType.PostalCode:
            case MixEnums.MixDataType.Upload:
            case MixEnums.MixDataType.Color:
            case MixEnums.MixDataType.Icon:
            case MixEnums.MixDataType.VideoYoutube:
            case MixEnums.MixDataType.TuiEditor:
            default:
                return(new JProperty(item.AttributeFieldName, item.StringValue));
            }
        }
예제 #2
0
				V_1 = Expression.Parameter(System.Type.GetTypeFromHandle(// 
				// Current member / type: System.Void Mix.Cms.Lib.ViewModels.MixModules.UpdateViewModel::LoadAttributeFields(Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction)
				// Exception in: System.Void LoadAttributeFields(Mix.Cms.Lib.Models.Cms.MixCmsContext,Microsoft.EntityFrameworkCore.Storage.IDbContextTransaction)
				// Specified method is not supported.
				// 
				// mailto: [email protected]


		private void LoadAttributes(MixCmsContext _context, IDbContextTransaction _transaction)
		{
			this.LoadAttributeData(_context, _transaction);
			this.LoadAttributeFields(_context, _transaction);
			stackVariable7 = this.get_Attributes();
			stackVariable8 = Mix.Cms.Lib.ViewModels.MixModules.UpdateViewModel.u003cu003ec.u003cu003e9__175_2;
			if (stackVariable8 == null)
			{
				dummyVar0 = stackVariable8;
				stackVariable8 = new Func<Mix.Cms.Lib.ViewModels.MixAttributeFields.UpdateViewModel, int>(Mix.Cms.Lib.ViewModels.MixModules.UpdateViewModel.u003cu003ec.u003cu003e9.u003cLoadAttributesu003eb__175_2);
				Mix.Cms.Lib.ViewModels.MixModules.UpdateViewModel.u003cu003ec.u003cu003e9__175_2 = stackVariable8;
			}
			V_2 = stackVariable7.OrderBy<Mix.Cms.Lib.ViewModels.MixAttributeFields.UpdateViewModel, int>(stackVariable8).GetEnumerator();
			try
			{
				while (V_2.MoveNext())
				{
					V_3 = new Mix.Cms.Lib.ViewModels.MixModules.UpdateViewModel.u003cu003ec__DisplayClass175_0();
					V_3.field = V_2.get_Current();
					V_4 = this.get_AttributeData().get_Data().get_Values().FirstOrDefault<Mix.Cms.Lib.ViewModels.MixAttributeSetValues.UpdateViewModel>(new Func<Mix.Cms.Lib.ViewModels.MixAttributeSetValues.UpdateViewModel, bool>(V_3.u003cLoadAttributesu003eb__3));
					if (V_4 == null)
					{
						stackVariable33 = new MixAttributeSetValue();
						stackVariable33.set_AttributeFieldId(V_3.field.get_Id());
						V_4 = new Mix.Cms.Lib.ViewModels.MixAttributeSetValues.UpdateViewModel(stackVariable33, _context, _transaction);
						V_4.set_DataType(V_3.field.get_DataType());
						V_4.set_AttributeFieldName(V_3.field.get_Name());
						V_4.set_Priority(V_3.field.get_Priority());
						this.get_AttributeData().get_Data().get_Values().Add(V_4);
					}
					V_4.set_Priority(V_3.field.get_Priority());
					V_4.set_Field(V_3.field);
				}
			}
			finally
			{
				if (V_2 != null)
				{
					V_2.Dispose();
				}
			}
			stackVariable57 = ViewModelBase<MixCmsContext, MixRelatedAttributeData, Mix.Cms.Lib.ViewModels.MixRelatedAttributeDatas.UpdateViewModel>.Repository;
			V_5 = Expression.Parameter(System.Type.GetTypeFromHandle(// 
예제 #3
0
        public static JProperty ToJProperty(
            this MixAttributeSetValue item,
            MixCmsContext _context,
            IDbContextTransaction _transaction)
        {
            UnitOfWorkHelper <MixCmsContext> .InitTransaction(
                _context, _transaction,
                out MixCmsContext context, out IDbContextTransaction transaction, out bool isRoot);

            switch (item.DataType)
            {
            case MixDataType.DateTime:
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixDataType.Date:
                if (!item.DateTimeValue.HasValue)
                {
                    if (DateTime.TryParseExact(
                            item.StringValue,
                            "MM/dd/yyyy HH:mm:ss",
                            CultureInfo.InvariantCulture,
                            DateTimeStyles.RoundtripKind,
                            out DateTime date))
                    {
                        item.DateTimeValue = date;
                    }
                }
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixDataType.Time:
                return(new JProperty(item.AttributeFieldName, item.DateTimeValue));

            case MixDataType.Double:
                return(new JProperty(item.AttributeFieldName, item.DoubleValue ?? 0));

            case MixDataType.Boolean:
                return(new JProperty(item.AttributeFieldName, item.BooleanValue));

            case MixDataType.Integer:
                return(new JProperty(item.AttributeFieldName, item.IntegerValue ?? 0));

            case MixDataType.Reference:
                return(new JProperty(item.AttributeFieldName, new JArray()));

            case MixDataType.Upload:
                string domain = MixService.GetConfig <string>(MixAppSettingKeywords.Domain);
                string url    = !string.IsNullOrEmpty(item.StringValue)
                   ? !item.StringValue.Contains(domain)
                        ? $"{MixService.GetConfig<string>(MixAppSettingKeywords.Domain)}{item.StringValue}"
                        : item.StringValue
                   : null;
                return(new JProperty(item.AttributeFieldName, url));

            case MixDataType.Custom:
            case MixDataType.Duration:
            case MixDataType.PhoneNumber:
            case MixDataType.Text:
            case MixDataType.Html:
            case MixDataType.MultilineText:
            case MixDataType.EmailAddress:
            case MixDataType.Password:
            case MixDataType.Url:
            case MixDataType.ImageUrl:
            case MixDataType.CreditCard:
            case MixDataType.PostalCode:
            case MixDataType.Color:
            case MixDataType.Icon:
            case MixDataType.VideoYoutube:
            case MixDataType.TuiEditor:
            default:
                return(new JProperty(item.AttributeFieldName, item.StringValue));
            }
            if (isRoot)
            {
                transaction.Dispose();
                context.Dispose();
            }
        }