public async Task <bool> AssignTeamCaptain(TeamCaptainView view)
        {
            var seasonInfo = await _seasonInfoRepository.GetCurrentSeasonAsync();

            var summoner = (await _summonerInfoRepository.GetAllForSummonerNamesAsync(new List <string> {
                view.SummonerName
            })).FirstOrDefault();
            var roster   = await _teamRosterRepository.GetByTeamNameAsync(view.RosterName.Trim(), seasonInfo.Id);

            if (summoner == null || roster == null)
            {
                return(false);
            }

            var entity = new TeamCaptainEntity
            {
                SummonerId   = summoner.Id,
                TeamRosterId = roster.Id
            };

            var captain = await _teamCaptainRepository.GetCaptainByRosterId(roster.Id);

            if (captain == null)
            {
                return(await _teamCaptainRepository.CreateCaptainAsync(entity));
            }
            else
            {
                await _teamCaptainRepository.DeleteCaptainAsync(captain);

                return(await _teamCaptainRepository.CreateCaptainAsync(entity));
            }
        }
Beispiel #2
0
 public async Task <bool> DeleteCaptainAsync(TeamCaptainEntity entity)
 {
     return(await _table.DeleteWhereAsync("SummonerId = @summonerId AND TeamRosterId = @teamRosterId",
                                          new { summonerId = entity.SummonerId, teamRosterId = entity.TeamRosterId }));
 }
Beispiel #3
0
 public async Task <bool> CreateCaptainAsync(TeamCaptainEntity entity)
 {
     return(await _table.InsertAsync(entity) == 1);
 }