rank endpoint done

This commit is contained in:
2021-11-07 14:00:18 -05:00
parent e232accdb1
commit e14f7fae74
18 changed files with 2536 additions and 25 deletions

View File

@@ -2,6 +2,7 @@ using System;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using TOOHUCardAPI.Data.Enums;
using TOOHUCardAPI.Data.Models;
using TOOHUCardAPI.Data.Repositories;
@@ -61,5 +62,31 @@ namespace TOOHUCardAPI.Data.Services
await _userRepository.UpdateUser(user);
_logger.LogInformation("User {SteamId} saved new pet data with model: {PetModel} and effect {PetEffect}", user.SteamId, petModel, petEffect);
}
public async Task UpdateUserAccountDetails(long steamid, long newAccountId, string newUsername)
{
User user = await _userRepository.GetUser(steamid);
user.AccountId = newAccountId;
user.Username = newUsername;
await _userRepository.UpdateUser(user);
}
public async Task UpdateUserMaxWave(long steamid, int wave, RankType rankType)
{
User user = await _userRepository.GetUser(steamid);
switch (rankType)
{
case RankType.Single:
user.MaxWave = Math.Max(wave, user.MaxWave);
break;
case RankType.Team:
user.MaxTeamWave = Math.Max(wave, user.MaxTeamWave);
break;
default:
throw new ArgumentOutOfRangeException(nameof(rankType), rankType, null);
}
await _userRepository.UpdateUser(user);
}
}
}