예제 #1
0
        public async Task <Banlist> AddOrUpdate(YugiohBanlist yugiohBanlist)
        {
            var format = await _formatService.FormatByAcronym(yugiohBanlist.BanlistType.ToString());

            if (format == null)
            {
                throw new ArgumentException($"Format with acronym '{yugiohBanlist.BanlistType.ToString()}' not found.");
            }

            var banlist = await _banlistService.BanlistById(yugiohBanlist.ArticleId);

            if (banlist == null)
            {
                var addCommand = new AddBanlistCommand
                {
                    Id          = yugiohBanlist.ArticleId,
                    FormatId    = format.Id,
                    Name        = yugiohBanlist.Title,
                    ReleaseDate = yugiohBanlist.StartDate
                };

                banlist = await _banlistService.Add(addCommand);
            }
            else
            {
                var updateCommand = new UpdateBanlistCommand
                {
                    Id          = yugiohBanlist.ArticleId,
                    FormatId    = format.Id,
                    Name        = yugiohBanlist.Title,
                    ReleaseDate = yugiohBanlist.StartDate
                };

                banlist = await _banlistService.Update(updateCommand);
            }

            var banlistCards = await _banlistCardsService.MapToBanlistCards(banlist.Id, yugiohBanlist.Sections);

            banlist.Cards = await _banlistService.Update(banlist.Id, new UpdateBanlistCardsCommand { BanlistCards = banlistCards });

            return(banlist);
        }
예제 #2
0
        public async Task <Banlist> Add(AddBanlistCommand command)
        {
            var createdUri = await _restClient.Post(_apiUrl, command);

            return(await _restClient.Get <Banlist>(createdUri.AbsoluteUri));
        }