Exemple #1
0
 private void InitializeProperties()
 {            
     SelectedStore = new Kios();
     KiosList = new ObservableCollection<Kios>();
     StoresOfOwner = new ObservableCollection<Kios>();
 }
        private async void ButtonSave_Click(object sender, RoutedEventArgs e)
        {
            ToggleProgressRing();
            bool check = false;
            if (txtStoreName.Text != "" && txtKiotNo.Text != "" && txtPhone.Text != null && cbMarket.SelectedValue != null)
            {
                if (tpOpenTime.Time < tpCloseTime.Time)
                {
                    Kios temp = new Kios();
                    temp.StoreName = txtStoreName.Text;
                    temp.KiotNo = txtKiotNo.Text;
                    temp.Phone = txtPhone.Text;
                    temp.MarketId = Convert.ToInt32(cbMarket.SelectedValue);
                    temp.OwnerId = MediateClass.UserVM.UserInfo.UserId;
                    temp.AcceptDiscount = float.Parse(txtAcceptDiscount.Text.ToString());
                    temp.OpenTime = tpOpenTime.Time;
                    temp.CloseTime = tpCloseTime.Time;
                    if (!KiosViewModel.isUpdate)
                    {
                        check = await MediateClass.KiotVM.InsertStore(temp, media);
                    }
                    else
                    {
                        temp.StoreId = MediateClass.KiotVM.SelectedStore.StoreId;
                        temp.Image = MediateClass.KiotVM.SelectedStore.Image;
                        temp.SasQuery = MediateClass.KiotVM.SelectedStore.SasQuery;
                        temp.Rate = MediateClass.KiotVM.SelectedStore.Rate;

                        check = await MediateClass.KiotVM.UpdateStore(temp, media);
                    }
                    if (check)
                    {
                        await new MessageDialog("Successful!", "Store").ShowAsync();
                        Frame.GoBack();
                    }
                    else
                        await new MessageDialog("Not successful!", "Store").ShowAsync();
                }
                else
                {
                    await new MessageDialog("Open time must be lower Close time!", "Store").ShowAsync();
                }
            }
            else
                await new MessageDialog("Please fill the infomation!", "Store").ShowAsync();
            ToggleProgressRing();
        }
Exemple #3
0
        public async Task<bool> UpdateStore(Kios store, StorageFile media)
        {
            try
            {
                if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
                {
                    if (store.Image == null || store.Image == "/Assets/LockScreenLogo.scale-200.png")
                    {
                        if (media == null)
                            store.Image = "/Assets/LockScreenLogo.scale-200.png";
                        else
                            store.Image = null;
                    }
                    JToken data = JToken.FromObject(store);
                    JToken result = await App.MobileService.InvokeApiAsync("Stores", data, HttpMethod.Put, null);
                    JObject response = JObject.Parse(result.ToString());

                    SelectedStore = response.ToObject<Kios>();
                    if (media != null)
                    {
                        await Functions.Instance.UploadImageToBlob("stores", SelectedStore.Image, SelectedStore.SasQuery, media);
                    }
                }
                else
                {
                    await new MessageDialog("You have not internet connection!", "Insert Product").ShowAsync();
                    return false;
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
                return false;
            }
            return true;
        }
 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;
         }
     }    
            
 }