Beispiel #1
0
        private static async Task <NamedId <DomainId> > CreateExperienceSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Experience")
                .AddString("Position", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your position in this job."))
                .AddString("Company", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The company or organization you worked for."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("The logo of the company or organization you worked for."))
                .AddDateTime("From", f => f
                             .Required()
                             .Hints("The start date."))
                .AddDateTime("To", f => f
                             .Hints("The end date, keep empty if you still work there."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
Beispiel #2
0
        private static async Task <NamedId <DomainId> > CreateEducationSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Education")
                .AddString("Degree", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The degree you got or achieved."))
                .AddString("School", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The school or university."))
                .AddAssets("Logo", f => f
                           .MustBeImage()
                           .Hints("The logo of the school or university."))
                .AddDateTime("From", f => f
                             .Required()
                             .Hints("The start date."))
                .AddDateTime("To", f => f
                             .Hints("The end date, keep empty if you still study there."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
Beispiel #3
0
        private static async Task <NamedId <DomainId> > CreateProjectsSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Projects")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name of your project."))
                .AddString("Description", f => f
                           .AsTextArea()
                           .Required()
                           .Hints("Describe your project."))
                .AddAssets("Image", f => f
                           .MustBeImage()
                           .Required()
                           .Hints("An image or screenshot for your project."))
                .AddString("Label", f => f
                           .AsTextArea()
                           .Hints("An optional label to categorize your project, e.g. 'Open Source'."))
                .AddString("Link", f => f
                           .Hints("An optional link to your project."))
                .AddNumber("Year", f => f
                           .Hints("The year, when you realized the project, used for sorting only."))
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
 public Task RunAsync(PublishTemplate publish)
 {
     var schema =
         SchemaBuilder.Create("Blogs")
         .AddString("Title", f => f
                    .Properties(p => p with
     {
         MaxLength = 100
     })
Beispiel #5
0
 private static async Task <NamedId <DomainId> > CreatePostsSchemaAsync(PublishTemplate publish)
 {
     var schema =
         SchemaBuilder.Create("Posts")
         .AddString("Title", f => f
                    .Properties(p => p with
     {
         MaxLength = 100
     })
Beispiel #6
0
 public Task RunAsync(PublishTemplate publish)
 {
     return(Task.WhenAll(
                CreateBasicsAsync(publish),
                CreateEducationSchemaAsync(publish),
                CreateExperienceSchemaAsync(publish),
                CreateProjectsSchemaAsync(publish),
                CreatePublicationsSchemaAsync(publish),
                CreateSkillsSchemaAsync(publish)));
 }
Beispiel #7
0
        private static async Task CreatePagesAsync(PublishTemplate publish)
        {
            var pagesId = await CreatePagesSchemaAsync(publish);

            await publish(new CreateContent
            {
                SchemaId = pagesId,
                Data     =
                    new ContentData()
                    .AddField("title",
                              new ContentFieldData()
                              .AddInvariant("About Me"))
                    .AddField("text",
                              new ContentFieldData()
                              .AddInvariant("I love Squidex and SciFi!")),
                Status = Status.Published
            });
        }
Beispiel #8
0
        private static async Task CreatePostsAsync(PublishTemplate publish)
        {
            var postsId = await CreatePostsSchemaAsync(publish);

            await publish(new CreateContent
            {
                SchemaId = postsId,
                Data     =
                    new ContentData()
                    .AddField("title",
                              new ContentFieldData()
                              .AddInvariant("My first post with Squidex"))
                    .AddField("text",
                              new ContentFieldData()
                              .AddInvariant("Just created a blog with Squidex. I love it!")),
                Status = Status.Published
            });
        }
Beispiel #9
0
        public Task RunAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Blogs")
                .AddString("Title", f => f
                           .Length(100)
                           .Required())
                .AddString("Slug", f => f
                           .Length(100)
                           .Required()
                           .Disabled())
                .AddString("Text", f => f
                           .Length(1000)
                           .Required()
                           .AsRichText())
                .Build();

            return(publish(schema));
        }
Beispiel #10
0
        private static async Task <NamedId <DomainId> > CreateSkillsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Skills")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name of the skill."))
                .AddString("Experience", f => f
                           .AsDropDown("Beginner", "Advanced", "Professional", "Expert")
                           .Required()
                           .ShowInList()
                           .Hints("The level of experience."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
Beispiel #11
0
        private static async Task <NamedId <DomainId> > CreateBasicsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Basics")
                .Singleton()
                .AddString("First Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your first name."))
                .AddString("Last Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("Your last name."))
                .AddAssets("Image", f => f
                           .MustBeImage()
                           .Hints("Your profile image."))
                .AddString("Profession", f => f
                           .AsTextArea()
                           .Required()
                           .Hints("Describe your profession."))
                .AddString("Summary", f => f
                           .AsTextArea()
                           .Hints("Write a short summary about yourself."))
                .AddString("Legal Terms", f => f
                           .AsTextArea()
                           .Hints("The terms to fulfill legal requirements."))
                .AddString("Github Link", f => f
                           .Hints("An optional link to your Github account."))
                .AddString("Blog Link", f => f
                           .Hints("An optional link to your Blog."))
                .AddString("Twitter Link", f => f
                           .Hints("An optional link to your Twitter account."))
                .AddString("LinkedIn Link", f => f
                           .Hints("An optional link to your LinkedIn  account."))
                .AddString("Email Address", f => f
                           .Hints("An optional email address to contact you."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
 private static async Task <NamedId <DomainId> > CreateBasicsSchemaAsync(PublishTemplate publish)
 {
     var command =
         SchemaBuilder.Create("Basics")
         .Singleton()
         .AddString("First Name", f => f
                    .Required()
                    .ShowInList()
                    .Hints("Your first name."))
         .AddString("Last Name", f => f
                    .Required()
                    .ShowInList()
                    .Hints("Your last name."))
         .AddAssets("Image", f => f
                    .Properties(p => p with
     {
         ExpectedType = AssetType.Image,
         MaxItems     = 1,
         MinItems     = 1
     })
        public async Task HandleAsync(CommandContext context, NextDelegate next)
        {
            if (context.IsCompleted && context.Command is CreateApp createApp && !string.IsNullOrWhiteSpace(createApp.Template))
            {
                if (templates.TryGetValue(createApp.Template, out var template))
                {
                    var appId = NamedId.Of(createApp.AppId, createApp.Name);

                    var publish = new PublishTemplate(command =>
                    {
                        command.AppId = appId;

                        return(context.CommandBus.PublishAsync(command));
                    });

                    await template.RunAsync(publish);
                }
            }

            await next(context);
        }
Beispiel #14
0
        private static async Task CreateBasicsAsync(PublishTemplate publish)
        {
            var postsId = await CreateBasicsSchemaAsync(publish);

            await publish(new UpdateContent
            {
                ContentId = postsId.Id,
                Data      =
                    new ContentData()
                    .AddField("firstName",
                              new ContentFieldData()
                              .AddInvariant("John"))
                    .AddField("lastName",
                              new ContentFieldData()
                              .AddInvariant("Doe"))
                    .AddField("profession",
                              new ContentFieldData()
                              .AddInvariant("Software Developer")),
                SchemaId = postsId
            });
        }
Beispiel #15
0
        private static async Task <NamedId <DomainId> > CreatePagesSchemaAsync(PublishTemplate publish)
        {
            var schema =
                SchemaBuilder.Create("Pages")
                .AddString("Title", f => f
                           .Length(100)
                           .Required()
                           .ShowInList()
                           .Hints("The title of the page."))
                .AddString("Text", f => f
                           .AsRichText()
                           .Required()
                           .Hints("The text of the page."))
                .AddString("Slug", f => f
                           .Disabled()
                           .Label("Slug (Autogenerated)")
                           .Hints("Autogenerated slug that can be used to identity the page."))
                .WithScripts(DefaultScripts.GenerateSlug)
                .Build();

            await publish(schema);

            return(NamedId.Of(schema.SchemaId, schema.Name));
        }
Beispiel #16
0
 public Task RunAsync(PublishTemplate publish)
 {
     return(Task.WhenAll(
                CreatePagesAsync(publish),
                CreatePostsAsync(publish)));
 }
Beispiel #17
0
        private static async Task <NamedId <DomainId> > CreatePublicationsSchemaAsync(PublishTemplate publish)
        {
            var command =
                SchemaBuilder.Create("Publications")
                .AddString("Name", f => f
                           .Required()
                           .ShowInList()
                           .Hints("The name or title of your publication."))
                .AddAssets("Cover", f => f
                           .MustBeImage()
                           .Hints("The cover of your publication."))
                .AddString("Description", f => f
                           .Hints("Describe the content of your publication."))
                .AddString("Link", f => f
                           .Hints("Optional link to your publication."))
                .Build();

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }