Example #1
0
        public BreweryViewModel()
        {
            Result = new BreweryInfoResult();

            if (!String.IsNullOrEmpty(App.ViewModel.UntappdUsername) && !String.IsNullOrEmpty(App.ViewModel.UntappdPassword)) {
                _client = new UntappdClient(App.ViewModel.UntappdUsername, App.ViewModel.UntappdPassword, App.ApiKey);
            } else {
                _client = new UntappdClient(App.ApiKey);
            }
        }
Example #2
0
        public void InitClient(StatusControl status)
        {
            _status = status;

            _client.BreweryInfoComplete += (sender, e) => {
                var res = e.Result.Results;
                res.Country = res.Country.ToUpper();
                res.Name = res.Name.ToLower();
                res.TwitterHandle = String.IsNullOrEmpty(res.TwitterHandle) ? null : "twitter: @" + res.TwitterHandle.ToLower();
                foreach (var beer in res.TopBeers) {
                    beer.Name = beer.Name.ToLower();
                    beer.Style = beer.Style.ToLower();
                }
                Result = res;

                _status.HideProgress();
            };

            _client.RemoteError += (sender, e) => {
                _status.HideProgress();
                _status.ShowError(e.Result.Error != null ? e.Result.Error.Message : e.Result.ErrorMessage);
            };
        }