Ejemplo n.º 1
0
        public static ContributorDto FromIdAndRole(string id, string role)
        {
            var result = new ContributorDto {
                ContributorId = id, Role = role
            };

            return(result);
        }
Ejemplo n.º 2
0
        public static ContributorDto FromIdAndRole(string id, string role, ApiController controller, string app)
        {
            var result = new ContributorDto {
                ContributorId = id, Role = role
            };

            return(result.CreateLinks(controller, app));
        }
Ejemplo n.º 3
0
        public static ContributorsDto FromApp(IAppEntity app, IAppPlansProvider plans, ApiController controller, bool isInvited)
        {
            var result = new ContributorsDto
            {
                Items = app.Contributors.Select(x => ContributorDto.FromIdAndRole(x.Key, x.Value, controller, app.Name)).ToArray(),
            };

            if (isInvited)
            {
                result.Metadata = new ContributorsMetadata
                {
                    IsInvited = isInvited.ToString()
                };
            }

            result.MaxContributors = plans.GetPlanForApp(app).MaxContributors;

            return(result.CreateLinks(controller, app.Name));
        }
Ejemplo n.º 4
0
        public static async Task <ContributorsDto> FromAppAsync(IAppEntity app, Resources resources, IUserResolver userResolver, IAppPlansProvider plans, bool invited)
        {
            var users = await userResolver.QueryManyAsync(app.Contributors.Keys.ToArray());

            var result = new ContributorsDto
            {
                Items = app.Contributors
                        .Select(x => ContributorDto.FromDomain(x.Key, x.Value))
                        .Select(x => x.CreateUser(users))
                        .Select(x => x.CreateLinks(resources))
                        .OrderBy(x => x.ContributorName)
                        .ToArray()
            };

            result.CreateInvited(invited);
            result.CreatePlan(app, plans);

            return(result.CreateLinks(resources));
        }
Ejemplo n.º 5
0
        public static async Task <ContributorsDto> FromAppAsync(IAppEntity app, ApiController controller, IUserResolver userResolver, IAppPlansProvider plans, bool invited)
        {
            var users = await userResolver.QueryManyAsync(app.Contributors.Keys.ToArray());

            var result = new ContributorsDto
            {
                Items =
                    app.Contributors
                    .Select(x => ContributorDto.FromIdAndRole(x.Key, x.Value))
                    .Select(x => x.WithUser(users))
                    .Select(x => x.WithLinks(controller, app.Name))
                    .OrderBy(x => x.ContributorName)
                    .ToArray()
            };

            result.WithInvited(invited);
            result.WithPlan(app, plans);

            return(result.CreateLinks(controller, app.Name));
        }