Пример #1
0
        private async Task SendCreditWarningNotifications(string accessToken, string userId, int creditLimit, int creditToEarn, NotificationType notificationType)
        {
            var credit = _loyaltyService.UserCredit(userId);

            if (credit > creditLimit)
            {
                return;
            }

            var notificationBaseUrl = AppSettingsProvider.NotificationBaseUrl;
            var sendNotificationUrl = AppSettingsProvider.SendNotification;
            var notificationModel   = new NotificationModel()
            {
                GameId           = 0,
                CreatedDate      = DateTime.Now,
                NotificationType = notificationType,
                UserId           = userId,
                UserCredits      = credit.GetValueOrDefault(),
                CreditsToEarn    = creditToEarn,
                WinStreakCount   = null,
                ImagePath        = null,
                IsActionTaken    = false,
            };

            await _httpHandler.AuthPostAsync(accessToken, notificationBaseUrl, sendNotificationUrl, JsonConvert.SerializeObject(notificationModel));
        }
Пример #2
0
        public async Task SyncLoyaltyTable(CreateOrUpdateLoyaltyViewModel model, string accessToken)
        {
            var baseUrl = AppSettingsProvider.LoyaltyBaseUrl;

            var api = AppSettingsProvider.CreateOrUpdateLoyalty;

            var messageBody = JsonConvert.SerializeObject(model);
            var result      = await _httpHandler.AuthPostAsync <CreateOrUpdateLoyaltyViewModel>(accessToken, baseUrl, api, messageBody);
        }
Пример #3
0
        public async Task SyncContactTable(string accessToken, string userId, string contactUserId)
        {
            var baseUrl = AppSettingsProvider.ChatBaseUrl;

            var api = AppSettingsProvider.CreateContact.Replace("{contactUserId}", userId);

            await _httpHandler.AuthPostAsync(accessToken, baseUrl, api, null);
        }
Пример #4
0
        public async Task SendAnswer(string accessToken, SendChoiceViewModel model)
        {
            var baseUrl = AppSettingsProvider.GameBaseUrl;

            var api = AppSettingsProvider.SendChoice;

            var messageBody = JsonConvert.SerializeObject(model);
            await _httpHandler.AuthPostAsync(accessToken, baseUrl, api, messageBody);
        }
Пример #5
0
        public async Task <bool> SyncGameTable(CreateOrUpdateGameModel model, string accessToken)
        {
            var baseUrl = AppSettingsProvider.GameBaseUrl;

            var api = AppSettingsProvider.CreateGameUrl;

            var messageBody = JsonConvert.SerializeObject(model);
            var result      = await _httpHandler.AuthPostAsync <CreateOrUpdateGameModel>(accessToken, baseUrl, api, messageBody);

            if (result != null)
            {
                return(true);
            }
            return(false);
        }
Пример #6
0
        public async Task <IEnumerable <Player> > GetItemsAsync(params object[] args)
        {
            //var guid = String.Empty;
            var spotId = args[0].ToString();

            var spotUrl             = AppSettingsManager.Settings["spotUrl"];
            var followingPlayersUrl = AppSettingsManager.Settings["followingPlayers"];

            Application.Current.Properties.TryGetValue("AccessToken", out object accessTokenObject);
            var accessToken = accessTokenObject == null ? string.Empty : accessTokenObject.ToString();

            players = await _httpHandler.AuthPostAsync <List <Player> >(accessToken, spotUrl, followingPlayersUrl, spotId);

            return(players);
        }
Пример #7
0
        public async Task <string> GetUserId(string token, string baseUrl = null, string api = null)
        {
            if (string.IsNullOrEmpty(baseUrl))
            {
                baseUrl = AppSettingsProvider.IdentityBaseUrl;
            }

            if (string.IsNullOrEmpty(api))
            {
                api = AppSettingsProvider.GetUserId;
            }

            var userId = await _httpHandler.AuthPostAsync <string>(token, baseUrl, api);

            return(userId);
        }
Пример #8
0
        private async Task <IReadOnlyList <string> > GetChallengerIds(GetChallengerIdsModel model)
        {
            if (string.IsNullOrEmpty(model.BaseUrl))
            {
                model.BaseUrl = AppSettingsProvider.LoyaltyBaseUrl;
            }

            if (string.IsNullOrEmpty(model.Api))
            {
                model.Api = AppSettingsProvider.FilterUsersUrl;
            }

            var message = JsonConvert.SerializeObject(model.FilterUsersViewModel);

            var userIds = await _httpHandler.AuthPostAsync <List <string> >(model.AccessToken, model.BaseUrl, model.Api, message);

            if (userIds.Any())
            {
                userIds.Except(NotAvailableUserIds(userIds.ToList()));
            }

            return(userIds);
        }
Пример #9
0
        public async Task <IEnumerable <Location> > GetItemsAsync(params object[] args)
        {
            //var guid = String.Empty;

            var spotUrl = AppSettingsManager.Settings["spotUrl"];

            var currentLocation = await _locationService.GetCurrentLocation();

            var getSpotsUrl = AppSettingsManager.Settings["spots"];

            var coordinateModel = new CoordinateModel()
            {
                Latitude = currentLocation.Latitude, Longitude = currentLocation.Longitude
            };
            var jsonBody = JsonConvert.SerializeObject(coordinateModel);

            Application.Current.Properties.TryGetValue("AccessToken", out object accessTokenObject);
            var accessToken   = accessTokenObject == null ? string.Empty : accessTokenObject.ToString();
            var nearLocations = await _httpHandler.AuthPostAsync <List <SpotListViewModel> >(accessToken, spotUrl, getSpotsUrl, jsonBody);

            #region static content
            //var newLocations = new List<Location>()
            //{
            //    new Location(){
            //        Id = guid = Guid.NewGuid().ToString(),
            //        Name = "Heybeliada Tennis Club",
            //        ShortDescription = "Greatest Tennis Club of the World",
            //        Description = "Very Magnificiant Tennis Club with a lot of blabla and blabla",
            //        Pin = new Pin(){
            //            ClassId = guid,
            //            Type = PinType.Place,
            //            Position = new Position(40.871517, 29.089059),
            //            Label = "Heybeli Tennis Club",
            //            Address = "Heybeli Tennis Club Detail Info"
            //        }
            //    },
            //    new Location(){
            //        Id = guid =  Guid.NewGuid().ToString(),
            //        Name = "Kınalıada Tennis Club",
            //        ShortDescription = "Greatest Tennis Club of the World",
            //        Description = "Very Magnificiant Tennis Club with a lot of blabla and blabla",
            //        Pin = new Pin()
            //        {
            //            ClassId = guid,
            //            Type = PinType.Place,
            //            Position = new Position(40.906027, 29.048176),
            //            Label = "Kınalı Tennis Club",
            //            Address = "Kınalı Tennis Club Detail Info"
            //        }
            //    },
            //    new Location(){
            //        Id = guid = Guid.NewGuid().ToString(),
            //        Name = "Burgazada Tennis Club",
            //        ShortDescription = "Greatest Tennis Club of the World",
            //        Description = "Very Magnificiant Tennis Club with a lot of blabla and blabla",
            //        Pin = new Pin()
            //        {
            //            ClassId = guid,
            //            Type = PinType.Place,
            //            Position = new Position(40.880651, 29.061132),
            //            Label = "Burgazada Tennis Club",
            //            Address = "Burgazada Tennis Club Detail Info"
            //        }
            //    },
            //    new Location(){
            //        Id = guid = Guid.NewGuid().ToString(),
            //        Name = "Suadiye Tennis Club",
            //        ShortDescription = "Greatest Tennis Club of the World",
            //        Description = "Very Magnificiant Tennis Club with a lot of blabla and blabla",
            //        Pin = new Pin()
            //        {
            //            ClassId = guid,
            //            Type = PinType.Place,
            //            Position = new Position(40.958429, 29.081837),
            //            Label = "Suadiye Tennis Club",
            //            Address = "Suadiye Tennis Club Detail Info"
            //        }
            //    },
            //    new Location(){
            //        Id = guid = Guid.NewGuid().ToString(),
            //        Name = "Kadıköy Tennis Club",
            //        ShortDescription = "Greatest Tennis Club of the World",
            //        Description = "Very Magnificiant Tennis Club with a lot of blabla and blabla",
            //        Pin = new Pin()
            //        {
            //            ClassId = guid,
            //            Type = PinType.Place,
            //            Position = new Position(40.991617, 29.025069),
            //            Label = "Kadıköy Tennis Club",
            //            Address = "Kadıköy Tennis Club Detail Info"
            //        }
            //    }
            //};
            #endregion
            foreach (var nearLocation in nearLocations)
            {
                var location = Mapper.Map <Location>(nearLocation);
                location.Pin = new Pin()
                {
                    ClassId  = Guid.NewGuid().ToString(),
                    Type     = PinType.Place,
                    Position = new Position(nearLocation.Latitude, nearLocation.Longitude),
                    Label    = location.Name,
                    Address  = location.ShortDescription
                };

                locations.Add(location);
            }

            return(locations);
        }