コード例 #1
0
ファイル: ContentsDto.cs プロジェクト: jrlost/squidex
        public static async Task <ContentsDto> FromContentsAsync(IResultList <IEnrichedContentEntity> contents, Resources resources,
                                                                 ISchemaEntity?schema, IContentWorkflow workflow)
        {
            var result = new ContentsDto
            {
                Total = contents.Total,
                Items = contents.Select(x => ContentDto.FromDomain(x, resources)).ToArray()
            };

            if (schema != null)
            {
                await result.AssignStatusesAsync(workflow, schema);

                await result.CreateLinksAsync(resources, workflow, schema);
            }

            return(result);
        }
コード例 #2
0
        public static async Task <ContentsDto> FromContentsAsync(IResultList <IEnrichedContentEntity> contents, Context context, ApiController controller,
                                                                 ISchemaEntity?schema, IContentWorkflow workflow)
        {
            var result = new ContentsDto
            {
                Total = contents.Total,
                Items = contents.Select(x => ContentDto.FromContent(context, x, controller)).ToArray()
            };

            if (schema != null)
            {
                await result.AssignStatusesAsync(workflow, schema);

                result.CreateLinks(controller, schema.AppId.Name, schema.SchemaDef.Name);
            }

            return(result);
        }
コード例 #3
0
        public static ContentDto FromCommand(CreateContent command, EntityCreatedResult <NamedContentData> result)
        {
            var now = SystemClock.Instance.GetCurrentInstant();

            var response = new ContentDto
            {
                Id             = command.ContentId,
                Data           = result.IdOrValue,
                Version        = result.Version,
                Created        = now,
                CreatedBy      = command.Actor,
                LastModified   = now,
                LastModifiedBy = command.Actor,
                Status         = command.Publish ? Status.Published : Status.Draft
            };

            return(response);
        }