Exemplo n.º 1
0
        public ActionResult Contents(string contentTypeFullName, CultureInfo culture = null)
        {
            var viewModel = new ContentsViewModel();

            if (!contentTypeFullName.IsNullOrEmpty())
            {
                viewModel.Contents    = _reflectionContentManager.LoadContentsByContentType(contentTypeFullName, 10);
                viewModel.ContentType = _reflectionContentManager.LoadContentType(contentTypeFullName);
                viewModel.Culture     = culture ?? _cultureManager.GetDefaultCulture(); //TODO : Faire la différence entre ContentManagementCulture & UICulture!!!
            }

            return(View(viewModel));
        }
        public IEnumerable <ModelMetadata> GetModelPropertiesMetadata(ModelMetadataProvider provider, object container, Type containerType)
        {
            ValidateContainerTypeIsContent(containerType);

            var contentType = GetContentType(container);

            //TODO: La bonne culture HttpContext.Current.Request.QueryString["CultureName"]

            //TODO: N+1 avec GetPropertyEditor
            var propertiesModelMetadata = contentType.Properties.Select(contentTypeProperty =>
            {
                //TODO: Revoir?
                var type = GetTypeOrDefaultType(contentTypeProperty);


                return(GetContentModelMetadata(provider, contentTypeProperty, containerType, () => (container == null ?
                                                                                                    contentTypeProperty.GetDefaultValue(type) :
                                                                                                    ((Content)container)[_cultureManager.GetDefaultCulture()][contentTypeProperty].GetValue(type)),
                                               type, contentTypeProperty.FullName));
            }).ToList();


            //Ajouter les propriétés "core" Ex. Culture, ContentTypeFullName

            propertiesModelMetadata.Add(GetContentCultureModelMetadata(provider, containerType, container));
            propertiesModelMetadata.Add(GetContentContentIdModelMetadata(provider, containerType, container));
            propertiesModelMetadata.Add(GetContentContentTypeFullNameModelMetadata(provider, containerType, contentType));

            return(propertiesModelMetadata);
        }
Exemplo n.º 3
0
        //TODO: Retourner Unchanged si c'est le cas
        public CreateOrUpdateReport <Content> GetNewOrUpdatedContent(object objectContent)
        {
            var contentId = _contentBuilder.GetContentId(objectContent);
            var content   = contentId.HasValue ? _contentManager.LoadContent(contentId.Value) : null;
            var action    = content == null ? CreateOrUpdateActions.Created : CreateOrUpdateActions.Updated;

            var cultureInfo = _contentBuilder.GetCultureInfo(objectContent) ?? _cultureInfoManager.GetDefaultCulture();

            if (action == CreateOrUpdateActions.Created)
            {
                var contentType = GetContentTypeFromType(objectContent.GetType());

                if (contentType == null)
                {
                    throw new Exception("No content type found for " + objectContent.GetType().FullName);
                }

                content = new Content(contentType, cultureInfo);
            }

            content = _contentBuilder.UpdateContent(objectContent, content, cultureInfo);

            return(new CreateOrUpdateReport <Content> {
                Action = action, Item = content
            });
        }