Card levels now save and get sent back properly
This commit is contained in:
21
TOOHUCardAPI/DTO/CardEncodingUtil.cs
Normal file
21
TOOHUCardAPI/DTO/CardEncodingUtil.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using TOOHUCardAPI.Data.Models;
|
||||
|
||||
namespace TOOHUCardAPI.DTO
|
||||
{
|
||||
public static class CardEncodingUtil
|
||||
{
|
||||
public static string EncodeLevelList(this IEnumerable<CardLevel> cardLevels)
|
||||
{
|
||||
return cardLevels.Select(cl => $"{cl.CardItemCode.Substring(6)}{cl.Level}").Aggregate(new StringBuilder(),
|
||||
(ret, current) =>
|
||||
{
|
||||
ret.Append(string.IsNullOrWhiteSpace(ret.ToString()) ? current : $"#{current}");
|
||||
return ret;
|
||||
}, builder => builder.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ namespace TOOHUCardAPI.DTO.PlayerData
|
||||
{
|
||||
PlayerDataGetResponseObjectPlayer responseObject = mapper.Map<PlayerDataGetResponseObjectPlayer>(user);
|
||||
responseObject.IsFirstWin = user.LastFirstWin.AddDays(1) < DateTime.Now ? 1 : 0;
|
||||
|
||||
responseObject.LevelList = user.CardLevels.EncodeLevelList();
|
||||
return responseObject;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user