rank endpoint done
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user