public async Task <string> Execute(ICommand command) { switch (command) { case UpdateCardsCacheCommand: { var progress = new Progress <(int current, int total)>(p => { ASF.ArchiLogger.LogGenericInfo( $"Updating cache: {p.current} out of {p.total}."); }); _cardsService.UpdateCache(progress).FireAndForget(); return("Cache update is started..."); } case SaveCardsCacheCommand: { await _cardsService.SaveCache(); return("Cache was saved."); } case LoadCardsCacheCommand: { await _cardsService.LoadCache(); return("Cache was loaded."); } case CountCardsInCacheCommand: { return($"Service have info about {_cardsService.CardsTotal} cards"); } case GetBadgeCraftsForMoney cmd: { var crafts = await _badgesService.GetBadgeCraftsForMoney(cmd.Money, cmd.PriceOverpay); var totalPrice = crafts.Sum(x => x.Cards.Sum(y => y.SellPrice)); var links = _badgesService.GetMultibuyLinks(crafts); return ($"Got {crafts.Count} badges for price of {totalPrice} cents.{Environment.NewLine}{string.Join(Environment.NewLine, links)}"); } default: throw new NotImplementedException(); } }