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); }; }
public void InitClient(StatusControl status) { _status = status; _client.UserInfoComplete += (sender, e) => { var user = e.Result.Results.User; user.FirstName = user.FirstName.ToLower(); user.LastName = user.LastName.ToLower(); user.Location = user.Location.ToUpper(); User = user; _status.HideProgress(); }; _client.UserFeedComplete += (sender, e) => { Recent.Clear(); foreach (var result in e.Result.Results.OrderByDescending(i => DateTime.Parse(i.CreatedAt))) { if (result != null) { Recent.Add(new ItemViewModel() { LineOne = result.BeerName.ToLower(), IdOne = result.BeerId.ToString(), LineTwo = result.BreweryName.ToLower(), IdTwo = result.BreweryId, LineThree = result.DisplayCreatedTimeAgo, LineFour = String.IsNullOrEmpty(result.CheckinComment) ? null : result.CheckinComment.ToLower() }); } } _status.HideProgress(); }; _client.RemoteError += (sender, e) => { _status.HideProgress(); _status.ShowError(e.Result.Error != null ? e.Result.Error.Message : e.Result.ErrorMessage); }; }
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); }; }
public void InitClient(StatusControl status) { _status = status; if (!String.IsNullOrEmpty(UntappdUsername) && !String.IsNullOrEmpty(UntappdPassword)) { _client = new UntappdClient(UntappdUsername, UntappdPassword, App.ApiKey); } else { _client = new UntappdClient(App.ApiKey); } _client.TrendingComplete += (sender, e) => { Trending.Clear(); foreach (var result in e.Result.Results) { Trending.Add(new ItemViewModel() { LineOne = result.BeerName.ToLower(), IdOne = result.BeerId.ToString(), LineTwo = result.BreweryName.ToLower(), IdTwo = result.BreweryId }); } _status.HideProgress(); }; _client.UserFeedComplete += (sender, e) => { if (e.Result.FeedType == "Friend") { Friends.Clear(); foreach (var result in e.Result.Results.OrderByDescending(i => DateTime.Parse(i.CreatedAt))) { if (result != null) { Friends.Add(new ItemViewModel() { LineOne = result.User.DisplayName.ToLower(), IdOne = result.User.UserName, LineTwo = result.BeerName.ToLower(), IdTwo = result.BeerId.ToString(), LineThree = result.BreweryName.ToLower(), IdThree = result.BreweryId, LineFour = result.DisplayCreatedTimeAgo, Image = result.User.AvatarUrl, LineFive = String.IsNullOrEmpty(result.CheckinComment) ? null : result.CheckinComment.ToLower() }); } } _status.HideProgress(); } else if (e.Result.FeedType == "User") { if (e.Result.Results.Length > 0) { // profile Recent.Clear(); foreach (var result in e.Result.Results.OrderByDescending(i => DateTime.Parse(i.CreatedAt))) { if (result != null) { Recent.Add(new ItemViewModel() { LineOne = result.BeerName.ToLower(), IdOne = result.BeerId.ToString(), LineTwo = result.BreweryName.ToLower(), IdTwo = result.BreweryId, LineThree = result.DisplayCreatedTimeAgo, LineFour = String.IsNullOrEmpty(result.CheckinComment) ? null : result.CheckinComment.ToLower() }); } } } _status.HideProgress(); } }; _client.UserInfoComplete += (sender, e) => { var user = e.Result.Results.User; if (user.UserName == UntappdUsername) { user.FirstName = user.FirstName.ToLower(); user.LastName = user.LastName.ToLower(); user.Location = user.Location.ToUpper(); User = user; } _status.HideProgress(); }; _client.BeerSearchResultsComplete += (sender, e) => { Results.Clear(); foreach (var result in e.Result.Results) { Results.Add(new ItemViewModel() { LineOne = result.Name.ToLower(), IdOne = result.BeerId.ToString(), LineTwo = result.BreweryName.ToLower(), IdTwo = result.BreweryId }); } _searchComplete = true; NotifyPropertyChanged("NoResults"); _status.HideProgress(); }; _client.RemoteError += (sender, e) => { _status.HideProgress(); _status.ShowError(e.Result.Error != null ? e.Result.Error.Message : e.Result.ErrorMessage); }; }
public void InitClient(StatusControl status) { _status = status; _client.BeerInfoComplete += (sender, e) => { var res = e.Result.Results; res.Brewery = res.Brewery.ToLower(); res.Name = res.Name.ToLower(); res.Style = res.Style.ToLower(); res.AvgRating = res.AvgRating / 5; res.YourRating = res.YourRating / 5; Result = res; _status.HideProgress(); }; _client.RemoteError += (sender, e) => { _status.HideProgress(); _status.ShowError(e.Result.Error != null ? e.Result.Error.Message : e.Result.ErrorMessage); }; }