예제 #1
0
        public async Task <IActionResult> UpdateSongForParty([FromBody] PartyCodeDTO partyCode)
        {
            PartyGoer user = new PartyGoer(User.FindFirstValue(ClaimTypes.NameIdentifier));

            if (await _partyService.IsUserHostingAPartyAsync(user))
            {
                Party party = await _partyService.GetPartyWithHostAsync(user);

                await _logService.LogUserActivityAsync(user.Id, $"User updated song for party with code {partyCode.PartyCode}");

                return(await UpdateCurrentSongForEveryoneInPartyAsync(party, user));
            }
            else if (await _partyService.IsUserPartyingAsync(user))
            {
                Party party = await _partyService.GetPartyWithAttendeeAsync(user);

                await _logService.LogUserActivityAsync(user.Id, $"User updated song for party with code {partyCode.PartyCode}");

                return(await UpdateCurrentSongForEveryoneInPartyAsync(party, user));
            }
            else
            {
                await _logService.LogUserActivityAsync(user.Id, $"User failed tp update song for party with code {partyCode.PartyCode}");

                return(BadRequest($"You are currently not hosting a party or attending a party: {partyCode.PartyCode}"));
            }
        }
예제 #2
0
        public async Task NewPartyWithHostHasNoAttendeesEmpty()
        {
            string partyCode = await _partyService.StartNewPartyAsync(PartyHost1);

            PartyCodeDTO partyCodeDTO = new PartyCodeDTO {
                PartyCode = partyCode
            };

            Assert.AreEqual(0, (await _partyService.GetPartyWithHostAsync(PartyHost1)).Listeners.Count);
        }