当前位置: 首页>>代码示例>>C#>>正文


C# ICommandBuilder.Execute方法代码示例

本文整理汇总了C#中ICommandBuilder.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# ICommandBuilder.Execute方法的具体用法?C# ICommandBuilder.Execute怎么用?C# ICommandBuilder.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICommandBuilder的用法示例。


在下文中一共展示了ICommandBuilder.Execute方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: MusicModule

        public MusicModule(IQueryBuilder queryBuilder, ICommandBuilder commandBuilder)
            : base("/music")
        {
            _queryBuilder = queryBuilder;
            _commandBuilder = commandBuilder;

            Get["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("music");

                var paging = this.BindAndValidate<Paging>();
                var result = _queryBuilder.For<IPagedEnumerable<TrackDto>>().With(paging);

                return Response.AsAccepted(result, new[] { "json", "m3u" }, model => Response.AsJson(model));
            };

            Post["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<AddTrack>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.Created
                };
            };

            Post["/tagged"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<MarkTrackWithTags>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.OK
                };
            };

            Delete["/tagged"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("music");

                var model = this.BindAndValidate<RemoreTagsFromTrack>();
                _commandBuilder.Execute(model);

                return new Response
                {
                    StatusCode = HttpStatusCode.OK
                };
            };
        }
开发者ID:andrewyakonyuk,项目名称:Vault,代码行数:59,代码来源:MusicModule.cs

示例2: AccountModule

        public AccountModule(ICommandBuilder commandBuilder, IQueryBuilder queryBuilder)
            : base("/account")
        {
            _commandBuilder = commandBuilder;
            _queryBuilder = queryBuilder;

            Get["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("account");

                var paging = this.BindAndValidate<Paging>();
                var result = _queryBuilder.For<IPagedEnumerable<UserDto>>().With(paging);

                return Response.AsJson(result);
            };

            Post["/"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresWriteClaim("account");

                var findByEmail = this.BindAndValidate<FindByEmail>();
                var emailAlreadyInUse = _queryBuilder.For<UserDto>().With(findByEmail) != null;
                if (emailAlreadyInUse)
                {
                    return new Response
                    {
                        StatusCode = HttpStatusCode.BadRequest
                    };
                }

                var user = this.BindAndValidate<CreateUser>();
                _commandBuilder.Execute(user);

                return new Response
                {
                    StatusCode = HttpStatusCode.Created
                };
            };

            Post["/{email}"] = _ =>
            {
                this.RequiresAuthentication();
                this.RequiresReadClaim("account");

                var credentials = this.BindAndValidate<Credentials>();
                var result = _queryBuilder.For<UserDto>().With(credentials);

                return Response.AsJson(result);
            };
        }
开发者ID:andrewyakonyuk,项目名称:Vault,代码行数:52,代码来源:AccountModule.cs


注:本文中的ICommandBuilder.Execute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。