Exemple #1
0
        async public Task <(IMessage, UserModel)> Process()
        {
            var subscriptionsByUser = await _repo.GetByUser(_user.Id);

            if (!subscriptionsByUser.Any())
            {
                return(new TextMessage("You have no subsctiptions"), _user);
            }
            return(new MultiTextMessage(subscriptionsByUser.Select(s => s.Uri)), _user);
        }
Exemple #2
0
        async public Task <(IMessage, UserModel)> Process()
        {
            var subscriptions = (await _repo.GetByUser(_user.Id)).ToDictionary(s => s.Uri);
            var snowfall      = await _snowForecastClient.GetSnowfall(subscriptions.Keys);

            if (!snowfall.Any())
            {
                return(new TextMessage("Nothing good"), _user);
            }
            var uris = snowfall
                       .Select(s => $"{subscriptions[s.Uri].GetResortName()}: {s.Snowfall}cm");

            return(new MultiTextMessage(uris), _user);
        }
        async public Task <(IMessage, UserModel)> Process()
        {
            if (_words.Length == 1)
            {
                var subscriptions = await _repo.GetByUser(_user.Id);

                if (subscriptions.Any() && subscriptions.Count() <= 10)
                {
                    var resorts = (new string[] { "all" })
                                  .Concat(subscriptions.Select(s => s.GetResortName()));
                    return(new ListMessage("What from?", "unsb ", resorts), _user);
                }
            }
            if (_words.Length != 2)
            {
                _user.LastCommand = string.Join(" ", _words);
                return(new TextMessage("Enter existing subscription link or all"), _user);
            }
            if (_words[1] != "all")
            {
                bool deleted = await _repo.Delete(_user.Id, _words[1]);

                if (!deleted)
                {
                    return(new TextMessage("Subscription not found"), _user);
                }
            }
            else
            {
                var subscriptions = await _repo.GetByUser(_user.Id);

                await Task.WhenAll(subscriptions
                                   .ToArray()
                                   .Select(s => _repo.Delete(s.UserId, s.Uri)));
            }
            return(new TextMessage("Done"), _user);
        }