示例#1
0
        public async Task PostRate(double rated)
        {
            int user = MediateClass.UserVM.UserInfo.UserId;
            int store = MediateClass.KiotVM.SelectedStore.StoreId;

            Rating UserRate = new Rating(user, store, rated);

            JObject result = new JObject();
            JToken body = JToken.FromObject(UserRate);
            try
            {
                if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
                {
                    var message = await App.MobileService.InvokeApiAsync("StatisticRatings", body, HttpMethod.Post, null);
                    result = JObject.Parse(message.ToString());

                    Kios temp = result.ToObject<Kios>();

                    UpdateDataLocal(temp, UserRate);
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
            }            
        }
示例#2
0
        public async void LoadStarRated()
        {
            int user = MediateClass.UserVM.UserInfo.UserId;
            int store = MediateClass.KiotVM.SelectedStore.StoreId;

            IDictionary<string, string> param = new Dictionary<string, string>
            {
                {"userId" , user.ToString()},
                {"storeId" , store.ToString()}
            };

            try
            {
                var result = await App.MobileService.InvokeApiAsync("StatisticRatings", HttpMethod.Get, param);
                JObject response = JObject.Parse(result.ToString());
                Rate = response.ToObject<Rating>();
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
            }
        }
示例#3
0
 private void UpdateDataLocal(Kios temp, Rating UserRate)
 {
     Rate.RateOfUser = UserRate.RateOfUser;
     if (MediateClass.KiotVM.SelectedStore.StoreId == temp.StoreId)
         MediateClass.KiotVM.SelectedStore.Rate = temp.Rate;
     for (int i=0;i<MediateClass.KiotVM.KiosList.Count;i++)
     {
         if(MediateClass.KiotVM.KiosList[i].StoreId == temp.StoreId)
         {
             MediateClass.KiotVM.KiosList[i].Rate = temp.Rate;
             break;
         }
     }
     
     for(int j = 0; j < MediateClass.CommentVM.CommentLstOfStore.Count; j++)
     {
         if(MediateClass.CommentVM.CommentLstOfStore[j].UserId == MediateClass.UserVM.UserInfo.UserId 
                 && MediateClass.CommentVM.CommentLstOfStore[j].StoreId == UserRate.StoreId)
         {
             MediateClass.CommentVM.CommentLstOfStore[j].Rated = UserRate.RateOfUser;
         }
     }    
            
 }
示例#4
0
 public RatingViewModel()
 {
     MediateClass.RateVm = this;
     _rate = new Rating();
     LoadStarRated();
 }