本文整理汇总了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
};
};
}
示例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);
};
}