Exemplo n.º 1
0
        public async Task <IActionResult> InviteMember([FromBody] InviteMemberCommand command,
                                                       CancellationToken cancellationToken)
        {
            var result = await _mediator.Send(command, cancellationToken);

            return(result.Failures.Any()
                                ? BadRequest(result.GenerateFailuresOutput()) as IActionResult
                                : CreatedAtRoute("get-invite", new { id = result.Data.Id }, result.Data));
        }
Exemplo n.º 2
0
        public static Faker <InviteMemberCommand> Valid(Guid?guildId = null, Guid?memberId = null)
        {
            return(new Faker <InviteMemberCommand>().CustomInstantiator(_ =>
            {
                var command = new InviteMemberCommand
                {
                    GuildId = guildId ?? Guid.NewGuid(),
                    MemberId = memberId ?? Guid.NewGuid()
                };

                const string routename = "get-invite";
                var urlHelper = UrlHelperMockBuilder.Create().SetupLink(routename).Build();
                command.SetupForCreation(urlHelper, routename, x => new { x.Id });
                return command;
            }));
        }
Exemplo n.º 3
0
        public async Task <ApiResponse <Invite> > Handle(InviteMemberCommand request, CancellationToken cancellationToken)
        {
            var invite = new Invite(request.MemberId, request.GuildId);

            return(new ApiResponse <Invite>(await _inviteRepository.InsertAsync(invite, cancellationToken)));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> InviteMember([FromBody] InviteMemberCommand command, CancellationToken cancellationToken)
        {
            command.SetupForCreation(Url, "get-invite", x => new { id = x.Id });

            return(await _mediator.Send(command, cancellationToken));
        }