public async Task <IActionResult> AddMemberToDivisionAsync(ClanId clanId, DivisionId divisionId, MemberId memberId)
        {
            var userId = HttpContext.GetUserId();

            var clan = await _clanService.FindClanAsync(clanId);

            if (clan == null)
            {
                return(this.NotFound("Clan does not exist."));
            }

            var result = await _clanService.AddMemberToDivisionAsync(
                clan,
                userId,
                divisionId,
                memberId);

            if (result.IsValid)
            {
                return(this.Ok("Division created."));
            }

            result.AddToModelState(ModelState);

            return(this.BadRequest(new ValidationProblemDetails(ModelState)));
        }
Beispiel #2
0
        public async Task <IActionResult> FindClanAsync(ClanId clanId)
        {
            var clan = await _clanService.FindClanAsync(clanId);

            if (clan == null)
            {
                return(this.NotFound("Clan not found."));
            }

            return(this.Ok(_mapper.Map <ClanDto>(clan)));
        }
Beispiel #3
0
        public async Task <IActionResult> DownloadLogoAsync(ClanId clanId)
        {
            var clan = await _clanService.FindClanAsync(clanId);

            if (clan == null)
            {
                return(this.NotFound("Clan doesn't exist."));
            }

            var logo = await _clanService.DownloadLogoAsync(clan);

            if (logo.Length == 0)
            {
                return(this.NoContent());
            }

            return(this.File(logo, "application/octet-stream"));
        }
Beispiel #4
0
        public async Task <IActionResult> FetchMembersAsync(ClanId clanId)
        {
            var clan = await _clanService.FindClanAsync(clanId);

            if (clan == null)
            {
                return(this.NotFound("Clan not found."));
            }

            var members = await _clanService.FetchMembersAsync(clan);

            if (!members.Any())
            {
                return(this.NoContent());
            }

            return(this.Ok(_mapper.Map <IEnumerable <MemberDto> >(members)));
        }
Beispiel #5
0
        public async Task Handle(ClanMemberAddedDomainEvent domainEvent, CancellationToken cancellationToken)
        {
            var clan = await _clanService.FindClanAsync(domainEvent.ClanId);

            await _serviceBusPublisher.PublishClanMemberAddedIntegrationEventAsync(domainEvent.UserId, clan !);

            await this.DeleteInvitationsAsync(domainEvent.UserId);

            await this.DeleteCandidaturesAsync(domainEvent.UserId);
        }
        public async Task Handle(InvitationCreatedDomainEvent domainEvent, CancellationToken cancellationToken)
        {
            var clan = await _clanService.FindClanAsync(domainEvent.Invitation.ClanId);

            await _serviceBusPublisher.PublishClanInvitationSentIntegrationEventAsync(domainEvent.Invitation.UserId, clan !);
        }
        public async Task Handle(ClanMemberRemovedDomainEvent domainEvent, CancellationToken cancellationToken)
        {
            var clan = await _clanService.FindClanAsync(domainEvent.ClanId);

            await _serviceBusPublisher.PublishClanMemberRemovedIntegrationEventAsync(domainEvent.UserId, clan !);
        }