Пример #1
0
        public CheckinResultViewModel()
        {
            Result = new CheckinResponse();

            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);
            }
        }
Пример #2
0
        public void InitClient(StatusControl status)
        {
            _status = status;

            _client.CheckinComplete += (sender, e) => {
                var res = e.Result;
                res.BeerDetails.Name = res.BeerDetails.Name.ToLowerInvariant();
                res.BeerDetails.Brewery = res.BeerDetails.Brewery.ToLowerInvariant();

                foreach (var badge in res.Badges) {
                    badge.Name = badge.Name.ToLowerInvariant();
                    badge.Description = badge.Description.ToLowerInvariant();
                }

                foreach (var rec in res.Recommendations) {
                    rec.Name = rec.Name.ToLowerInvariant();
                    rec.BreweryName = rec.BreweryName.ToLowerInvariant();
                }

                Result = res;
                _status.HideProgress();
            };

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