コード例 #1
0
ファイル: ChampionService.cs プロジェクト: thuanssss/db-es.tk
        public async Task <bool> CreateChampion(ActionCreateChampionParameter model)
        {
            var champions = await GetAllChampion() ?? new List <Champion>();

            champions = champions.OrderBy(a => a.Id).ToList();

            var championFind = champions.FirstOrDefault(a => a.Name == model.Name);

            if (championFind != null)
            {
                return(true);
            }

            championFind = new Champion
            {
                Name = model.Name,
                Id   = champions?.LastOrDefault()?.Id + 1 ?? 1
            };

            champions.Add(championFind);

            _firebaseService.PutChampions(champions);

            _cacheService.ClearCacheByKey(KeyListChampion);

            return(true);
        }