示例#1
0
    internal static void BindModel(ContentItemSave model, IContent persistedContent,
                                   ContentModelBinderHelper modelBinderHelper, IUmbracoMapper umbracoMapper)
    {
        model.PersistedContent = persistedContent;

        //create the dto from the persisted model
        if (model.PersistedContent != null)
        {
            foreach (ContentVariantSave variant in model.Variants)
            {
                //map the property dto collection with the culture of the current variant
                variant.PropertyCollectionDto = umbracoMapper.Map <ContentPropertyCollectionDto>(
                    model.PersistedContent,
                    context =>
                {
                    // either of these may be null and that is ok, if it's invariant they will be null which is what is expected
                    context.SetCulture(variant.Culture);
                    context.SetSegment(variant.Segment);
                });

                //now map all of the saved values to the dto
                modelBinderHelper.MapPropertyValuesFromSaved(variant, variant.PropertyCollectionDto);
            }
        }
    }
示例#2
0
 public ContentItemBinder(
     IJsonSerializer jsonSerializer,
     IUmbracoMapper umbracoMapper,
     IContentService contentService,
     IContentTypeService contentTypeService,
     IHostingEnvironment hostingEnvironment)
 {
     _jsonSerializer     = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer));
     _umbracoMapper      = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
     _contentService     = contentService ?? throw new ArgumentNullException(nameof(contentService));
     _contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
     _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     _modelBinderHelper  = new ContentModelBinderHelper();
 }
示例#3
0
 public MemberBinder(
     IJsonSerializer jsonSerializer,
     IHostingEnvironment hostingEnvironment,
     IShortStringHelper shortStringHelper,
     IUmbracoMapper umbracoMapper,
     IMemberService memberService,
     IMemberTypeService memberTypeService)
 {
     _jsonSerializer     = jsonSerializer ?? throw new ArgumentNullException(nameof(jsonSerializer));
     _hostingEnvironment = hostingEnvironment ?? throw new ArgumentNullException(nameof(hostingEnvironment));
     _shortStringHelper  = shortStringHelper ?? throw new ArgumentNullException(nameof(shortStringHelper));
     _umbracoMapper      = umbracoMapper ?? throw new ArgumentNullException(nameof(umbracoMapper));
     _memberService      = memberService ?? throw new ArgumentNullException(nameof(memberService));
     _memberTypeService  = memberTypeService ?? throw new ArgumentNullException(nameof(memberTypeService));
     _modelBinderHelper  = new ContentModelBinderHelper();
 }