Exemplo n.º 1
0
        public static IRoutingBuilder AddTokensController(this IRoutingBuilder builder, AccountsRoleConfiguration roles)
        {
            builder.AddController <TokensController>(controller =>
            {
                controller.AddRoute("tokens", c => c.Create(From.Body <CreateTokenRequest>()))
                .HttpPost();

                controller.AddRoute("tokens", c => c.Read())
                .HttpGet()
                .Authorize();

                controller.AddRoute("tokens/{tokenId}", c => c.Delete(From.Route <DeleteTokenRequest>()))
                .HttpDelete()
                .Authorize();

                controller.AddRoute("tokens", c => c.Refresh(From.Body <RefreshTokenRequest>()))
                .HttpPut();

                controller.AddRoute("admin/tokens/{accountId}", c => c.AdminReadById(From.Route <int>()))
                .HttpGet()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/tokens/{tokenId}",
                                    c => c.AdminDeleteById(From.Route <AdminDeleteByIdTokenRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
Exemplo n.º 2
0
        public static IRoutingBuilder AddTranslatorsController(this IRoutingBuilder builder, MangasRoleConfiguration roles)
        {
            builder.AddController <TranslatorsController>(controller =>
            {
                controller.AddRoute("translators", c => c.Read(From.Query <FilterRequest>()))
                .HttpGet();

                controller.AddRoute("translators/{mangaId}",
                                    c => c.ReadById(From.Route <int>(), From.Query <FilterRequest>()))
                .HttpGet();

                controller.AddRoute("admin/translators", c => c.AdminCreate(From.Body <AdminCreateTranslatorRequest>()))
                .HttpPost()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/translators/{translatorId}",
                                    c => c.AdminUpdate(From.Route <int>(), From.Body <AdminUpdateTranslatorRequest>()))
                .HttpPut()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/translators/{translatorId}",
                                    c => c.AdminDelete(From.Route <AdminDeleteTranslatorRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
        public static IRoutingBuilder AddReviewsController(this IRoutingBuilder builder, ReviewsRoleConfiguration roles)
        {
            builder.AddController <ReviewsController>(controller =>
            {
                controller.AddRoute("reviews", c => c.Read(From.Query <FilterRequest>()))
                .HttpGet()
                .Authorize();

                controller.AddRoute("{mangaId}/reviews", c => c.ReadById(From.Route <int>(), From.Query <FilterRequest>()))
                .HttpGet();

                controller.AddRoute("{mangaId}/reviews", c => c.Create(From.Route <int>(), From.Body <CreateReviewRequest>()))
                .HttpPost()
                .Authorize();

                controller.AddRoute("reviews/{id}", c => c.Update(From.Route <int>(), From.Body <UpdateReviewRequest>()))
                .HttpPut()
                .Authorize();

                controller.AddRoute("reviews/{id}", c => c.Delete(From.Route <DeleteReviewRequest>()))
                .HttpDelete()
                .Authorize();

                controller.AddRoute("admin/reviews/{id}",
                                    c => c.AdminUpdateById(From.Route <int>(), From.Body <AdminUpdateByIdReviewRequest>()))
                .HttpPut()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/reviews/{id}", c => c.AdminDeleteById(From.Route <AdminDeleteByIdReviewRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
        public static IRoutingBuilder AddPagesController(this IRoutingBuilder builder, MangasRoleConfiguration roles)
        {
            builder.AddController <PagesController>(controller =>
            {
                controller.AddRoute("pages/{chapterId}", c => c.Read(From.Route <int>(), From.Query <FilterRequest>()))
                .HttpGet();

                // TODO:
                // controller.AddRoute("pages/{pageId}", c => c.ReadById(From.Route<int>()))
                //  .HttpGet();

                controller.AddRoute("admin/{chapterId}/pages",
                                    c => c.AdminCreate(From.Route <int>(), From.Body <AdminCreatePageRequest>()))
                .HttpPost()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/pages/{pageId}",
                                    c => c.AdminUpdate(From.Route <int>(), From.Body <AdminUpdatePageRequest>()))
                .HttpPut()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/pages/{pageId}", c => c.AdminDelete(From.Route <AdminDeletePageRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
Exemplo n.º 5
0
        public static IRoutingBuilder AddBookmarksController(this IRoutingBuilder builder, MangasRoleConfiguration roles)
        {
            builder.AddController <BookmarksController>(controller =>
            {
                controller.AddRoute("bookmarks", c => c.Read(From.Query <FilterByMangaChapterAndPageIdRequest>()))
                .HttpGet()
                .Authorize();

                controller.AddRoute("bookmarks", c => c.Create(From.Body <CreateBookmarkRequest>()))
                .HttpPost()
                .Authorize();

                controller.AddRoute("bookmarks/{bookmarkId}", c => c.Delete(From.Route <DeleteBookmarkRequest>()))
                .HttpDelete()
                .Authorize();

                controller.AddRoute("admin/bookmarks/{accountId}",
                                    c => c.AdminReadById(From.Route <int>(), From.Query <FilterByMangaChapterAndPageIdRequest>()))
                .HttpGet()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/bookmarks/{bookmarkId}",
                                    c => c.AdminDeleteById(From.Route <AdminDeleteByIdBookmarkRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
        public ProfileRouteComponent()
        {
            Route(x => x.Create(From.Body <CreateProfileRequestViewModel>()))
            .HttpPost();

            Route(x => x.Read(From.Query <ReadProfileRequestViewModel>()))
            .HttpGet();
        }
 public TaskRouteComponent()
 {
     Route(
         "complete",
         c => c.Complete(
             From.Query <string>(),
             From.Body <TaskCompleteViewModel>()))
     .HttpPost();
 }
Exemplo n.º 8
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers()
            .AddRouting(routing =>
                        routing.AddController <OrdersController>("orders", controller =>
            {
                controller.AddRoute("{id}", c => c.GetById(From.Route <int>("id")))
                .HttpGet();

                controller.AddRoute(c => c.Create(From.Body <OrderModel>()))
                .HttpPost();
            }));
        }
        public static IRoutingBuilder AddProfilesController(this IRoutingBuilder builder, ProfilesRoleConfiguration roles)
        {
            builder.AddController <ProfilesController>(controller =>
            {
                controller.AddRoute("profiles", c => c.Create(From.Body <CreateProfileRequest>()))
                .HttpPost()
                .Authorize();

                controller.AddRoute("profiles", c => c.Read())
                .HttpGet()
                .Authorize();

                controller.AddRoute("{accountId}/profile", c => c.ReadById(From.Route <int>()))
                .HttpGet()
                .Authorize();

                controller.AddRoute("profiles", c => c.Update(From.Body <UpdateProfileRequest>()))
                .HttpPut()
                .Authorize();

                controller.AddRoute("profiles", c => c.Delete(From.Any <DeleteProfileRequest>()))
                .HttpDelete()
                .Authorize();

                controller.AddRoute("admin/profiles", c => c.AdminRead(From.Query <FilterRequest>()))
                .HttpGet()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/profiles/{profileId}", c => c.AdminReadById(From.Route <int>()))
                .HttpGet()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/profiles/{profileId}",
                                    c => c.AdminUpdateById(From.Body <AdminUpdateByIdProfileRequest>(), From.Route <int>()))
                .HttpPut()
                .Authorize(roles.Admin);

                controller.AddRoute("admin/profiles/{profileId}", c => c.AdminDeleteById(From.Route <AdminDeleteByIdProfileRequest>()))
                .HttpDelete()
                .Authorize(roles.Admin);
            });

            return(builder);
        }
Exemplo n.º 10
0
        public void FromBody()
        {
            services.AddMvcCore()
            .AddRouting(routing =>
                        routing.AddController <TestController>("test", controller =>
                                                               controller.AddRoute("works", c => c.TestMethod(From.Body <string>()))));

            var provider = services.BuildServiceProvider();
            var options  = provider.GetRequiredService <IOptions <RoutingOptions> >().Value;

            var(_, parameterMetadata) = Assert.Single(options.Parameters);
            Assert.Equal(BindingSource.Body, parameterMetadata.BindingSource);
        }
Exemplo n.º 11
0
        public IActionResult Create(OrderModel model)
        {
            var action = Url.Action <OrdersController>(c => c.Create(From.Body <OrderModel>()));

            return(Created(action, model));
        }
Exemplo n.º 12
0
 public QuizRouteComponent()
 {
     Route(x => x.Result(From.Query <string>(), From.Body <QuizRequestViewModel>()))
     .HttpPost();
 }