コード例 #1
0
 public async void GetCommentOfStore(TYPEGET typeGet, TYPE type=0)
 {
     string lastId = "";
     int storeId = MediateClass.KiotVM.SelectedStore.StoreId;
     if (typeGet == TYPEGET.MORE)
     {
         if (CommentLstOfStore.Count != 0)
         {
             if (type == TYPE.OLD)
                 lastId = CommentLstOfStore.Min(x => x.Id).ToString();
             else
                 lastId = CommentLstOfStore.Max(x => x.Id).ToString();
         }
     }
     else
         lastId = "-1";
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"storeId" , storeId.ToString()},
         {"commentId" , lastId},
         {"type" , type.ToString()}
     };
     if(lastId != "")
         await SendData(typeGet, type, param);
 } 
コード例 #2
0
ファイル: KiosViewModel.cs プロジェクト: monpham2310/PayBay
 public async void LoadMoreStore(TYPEGET typeGet,TYPE type=0)
 {
     string lastId = "";
     int marketId = MediateClass.MarketVM.SelectedMarket.MarketId;
     if (typeGet == TYPEGET.MORE)
     {
         if (KiosList.Count != 0)
         {
             if (type == TYPE.OLD)
                 lastId = KiosList.Min(x => x.StoreId).ToString();
             else
                 lastId = KiosList.Max(x => x.StoreId).ToString();
         }
     }
     else
         lastId = "-1";
           
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"marketId", marketId.ToString()},
         {"storeId" , lastId},
         {"type" , type.ToString()}
     };
     if(lastId != "")
         await SendData(typeGet, type, param);
 }
コード例 #3
0
 private async Task SendData(TYPEGET typeGet, TYPE type, IDictionary<string,string> param)
 {
     try
     {
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("Comments", HttpMethod.Get, param);
                 JArray response = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.START)
                 {
                     CommentLstOfStore = response.ToObject<ObservableCollection<Comment>>();
                 }
                 else
                 {
                     ObservableCollection<Comment> more = response.ToObject<ObservableCollection<Comment>>();
                     if (type == TYPE.OLD)
                     {
                         foreach (var item in more)
                         {
                             CommentLstOfStore.Add(item);
                         }
                     }
                     else
                     {
                         for (int i = 0; i < more.Count; i++)
                         {
                             CommentLstOfStore.Insert(i, more[i]);
                         }
                     }
                 }                        
             }
         }
     }
     catch (Exception ex)
     {                
         await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
     }
     finally
     {
         isResponsed = false;
     }
 }
コード例 #4
0
ファイル: MarketViewModel.cs プロジェクト: monpham2310/PayBay
 private async Task SendData(TYPEGET typeGet, TYPE type, IDictionary<string, string> param)
 {
     try
     {
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("Markets", HttpMethod.Get, param);
                 JArray response = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.MORE)
                 {
                     ObservableCollection<Market> data = response.ToObject<ObservableCollection<Market>>();
                     if (type == TYPE.OLD)
                     {
                         foreach (var item in data)
                         {
                             MarketItemList.Add(item);
                         }
                     }
                     else {
                         for (int i = 0; i < data.Count; i++)
                         {
                             MarketItemList.Insert(i, data[i]);
                         }
                     }
                 }
                 else
                     MarketItemList = response.ToObject<ObservableCollection<Market>>();
                 isResponsed = false;
             }
         }
     }
     catch (Exception ex)
     {
         isResponsed = false;
         await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
     }
 }
コード例 #5
0
ファイル: MarketViewModel.cs プロジェクト: monpham2310/PayBay
 public async void LoadMoreMarket(string name, TYPEGET type, TYPE isOld = 0)
 {
     string lastId = "";
     if (type == TYPEGET.MORE)
     {
         if (MarketItemList.Count != 0)
         {
             if (isOld == TYPE.OLD)
                 lastId = MarketItemList.Min(x => x.MarketId).ToString();
             else
                 lastId = MarketItemList.Max(x => x.MarketId).ToString();
         }
     }
     else
         lastId = "-1";
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"id" , lastId},
         {"name" , name},
         {"type" , isOld.ToString()}
     };
     if(lastId != "")
         await SendData(type, isOld, param);
 }
コード例 #6
0
 private async Task SendData(TYPEGET typeGet, TYPE type, MessageInfo param, IDictionary<string,string> arg)
 {
     try
     {
         JToken body = JToken.FromObject(param);
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("MessageInboxes", body, HttpMethod.Get, arg);
                 JArray response = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.START)
                 {
                     MessageList = response.ToObject<ObservableCollection<MessageInbox>>();
                 }
                 else
                 {
                     ObservableCollection<MessageInbox> more = response.ToObject<ObservableCollection<MessageInbox>>();
                     if (type == TYPE.OLD)
                     {
                         for (int i = 0; i < more.Count; i++)
                         {
                             MessageList.Insert(i, more[i]);
                         }
                     }
                     else
                     {                                
                         foreach (var item in more)
                         {
                             MessageList.Add(item);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         await new MessageDialog(ex.Message.ToString(), "Message!").ShowAsync();
     }
     finally
     {
         isResponsed = false;
     }
 }
コード例 #7
0
        public async void LoadInboxHitory(TYPEGET typeGet, TYPE type = TYPE.OLD)
        {          
            int userID = MediateClass.UserVM.UserInfo.UserId;
            int userChat = UserChated.UserID;
            int msgId = -1;
            if(typeGet == TYPEGET.MORE)
            {
                if(type == TYPE.OLD)
                {
                    msgId = MessageList.Min(x => x.MessageId);
                }
                else
                {
                    msgId = MessageList.Max(x => x.MessageId);
                }
            }

            MessageInfo msg = new MessageInfo(msgId, userID, userChat, type);

            IDictionary<string, string> param = new Dictionary<string, string>
            {
                {"type" , "1"}
            };
                        
            await SendData(typeGet, type, msg, param);
        }
コード例 #8
0
        public async Task UserComment(string content, int storeId, TYPEGET type, bool inKios=false)
        {
            UserInfo currentUser = MediateClass.UserVM.UserInfo;
            Comment comment = new Comment();
            comment.CommentDate = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
            comment.StoreId = storeId;
            comment.UserId = currentUser.UserId;
            comment.Username = currentUser.Username;
            comment.Avatar = currentUser.Avatar;
            comment.Content = content;

            JToken body = JToken.FromObject(comment);

            try
            {
                if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
                {
                    if (!isCommented)
                    {
                        isCommented = true;
                        JToken result = await App.MobileService.InvokeApiAsync("Comments", body, HttpMethod.Post, null);
                        //JArray response = JArray.Parse(result.ToString());                        
                        //ObservableCollection<Comment> updateCmt = response.ToObject<ObservableCollection<Comment>>();
                        if (!inKios)
                        {
                            //CommentLstOfStore = updateCmt;
                            GetCommentOfStore(TYPEGET.START);
                        }
                        else
                        {
                            //for (int i = 0; i < updateCmt.Count; i++)
                            //{
                            //    CommentLstOfStore.Insert(i, updateCmt[i]);
                            //}
                            GetCommentOfStore(TYPEGET.MORE, TYPE.NEW);
                        }
                    }                    
                }
            }
            catch (Exception ex)
            {                
                await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
            }
            finally
            {
                isCommented = false;
            }   
        }
コード例 #9
0
 private async Task SendData(TYPEGET typeGet, TYPE type, IDictionary<string,string> param)
 {                     
     try
     {
         if (NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("SaleInfoes", HttpMethod.Get, param);
                 JArray sales = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.MORE)
                 {
                     ObservableCollection<AdvertiseItem> moreSale = sales.ToObject<ObservableCollection<AdvertiseItem>>();
                     if (type == TYPE.OLD)
                     {
                         foreach (var item in moreSale)
                         {
                             SaleList.Add(item);
                         }
                     }
                     else {
                         for (int i = 0; i < moreSale.Count; i++)
                         {
                             SaleList.Insert(i, moreSale[i]);
                         }
                     }
                 }
                 else
                     SaleList = sales.ToObject<ObservableCollection<AdvertiseItem>>();                        
             }
         }
     }
     catch (Exception ex)
     {                
         await new MessageDialog(ex.Message.ToString(), "Notification!").ShowAsync();
     }
     finally
     {
         isResponsed = false;
     }
 }
コード例 #10
0
        public async void GetSaleOfOwner(TYPEGET typeGet, TYPE type = TYPE.OLD)
        {
            try
            {
                JArray result = new JArray();
                int lastId = -1;
                if (typeGet == TYPEGET.MORE)
                {
                    if (SaleOfStoreOwner.Count != 0)
                    {
                        if (type == TYPE.OLD)
                            lastId = SaleOfStoreOwner.Min(x => x.SaleId);
                        else
                            lastId = SaleOfStoreOwner.Max(x => x.SaleId);
                    }
                }
                int ownerId = MediateClass.UserVM.UserInfo.UserId;
                SaleItem saleInfo = new SaleItem(lastId, ownerId, type);
                JToken body = JToken.FromObject(saleInfo);

                if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
                {
                    var response = await App.MobileService.InvokeApiAsync("SaleInfoes", body, HttpMethod.Get, null);
                    result = JArray.Parse(response.ToString());
                    ObservableCollection<AdvertiseItem> more = result.ToObject<ObservableCollection<AdvertiseItem>>();
                    if (typeGet == TYPEGET.START)
                    {
                        SaleOfStoreOwner = more;
                    }
                    else
                    {
                        if (type == TYPE.OLD)
                        {
                            foreach (var item in more)
                            {
                                SaleOfStoreOwner.Add(item);
                            }
                        }
                        else
                        {
                            for (int i = 0; i < more.Count; i++)
                            {
                                SaleOfStoreOwner.Insert(i, more[i]);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Load Sale").ShowAsync();
            }
        }
コード例 #11
0
 public async void LoadMoreSale(string title, TYPEGET type, TYPE isOld=0)
 {
     string lastId = "";
     if (type == TYPEGET.MORE)
     {
         if (SaleList.Count != 0)
         {
             if (isOld == TYPE.OLD)
                 lastId = SaleList.Min(x => x.SaleId).ToString();
             else
                 lastId = SaleList.Max(x => x.SaleId).ToString();
         }
     }
     else
         lastId = "-1";
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"id" , lastId},
         {"title" , title},
         {"type" , isOld.ToString()}
     };
     if(lastId != "")
         await SendData(type, isOld, param);
 }
コード例 #12
0
        public async void GetNewProductList(TYPEGET typeGet, TYPE type = TYPE.OLD)
        {
            try
            {
                JArray result = new JArray();
                int lastId = -1;
                if (typeGet == TYPEGET.MORE)
                {
                    if (NewProductList.Count != 0)
                    {
                        if (type == TYPE.OLD)
                            lastId = NewProductList.Min(x => x.ProductId);
                        else
                            lastId = NewProductList.Max(x => x.ProductId);
                    }
                }

                IDictionary<string, string> param = new Dictionary<string, string>
                {
                    {"typeProduct" , type.ToString()},
                    {"productId" , lastId.ToString()}
                };

                if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
                {
                    if (!isResponse)
                    {
                        isResponse = true;
                        var response = await App.MobileService.InvokeApiAsync("ProductStatistics", HttpMethod.Get, param);
                        result = JArray.Parse(response.ToString());
                        ObservableCollection<Product> more = result.ToObject<ObservableCollection<Product>>();
                        if (typeGet == TYPEGET.START)
                        {
                            NewProductList = more;
                        }
                        else
                        {
                            if (type == TYPE.OLD)
                            {
                                foreach (var item in more)
                                {
                                    NewProductList.Add(item);
                                }
                            }
                            else
                            {
                                for (int i = 0; i < more.Count; i++)
                                {
                                    NewProductList.Insert(i, more[i]);
                                }
                            }
                        }
                    }                    
                }
            }
            catch (Exception ex)
            {
                await new MessageDialog(ex.Message.ToString(), "Load Product").ShowAsync();
            }
            finally
            {
                isResponse = false;
            }
        }
コード例 #13
0
 private async Task SendData(TYPEGET typeGet, TYPE type, IDictionary<string, string> param)
 {
     try
     {
         if (Utilities.Helpers.NetworkHelper.Instance.HasInternetConnection)
         {
             if (!isResponsed)
             {
                 isResponsed = true;
                 JToken result = await App.MobileService.InvokeApiAsync("Products", HttpMethod.Get, param);
                 JArray products = JArray.Parse(result.ToString());
                 if (typeGet == TYPEGET.MORE)
                 {
                     ObservableCollection<Product> moreProduct = products.ToObject<ObservableCollection<Product>>();
                     if (type == TYPE.OLD)
                     {
                         foreach (var item in moreProduct)
                         {
                             ProductList.Add(item);
                         }
                     }
                     else
                     {
                         for (int i = 0; i < moreProduct.Count; i++)
                         {
                             ProductList.Insert(i, moreProduct[i]);
                         }
                     }
                 }
                 else
                     ProductList = products.ToObject<ObservableCollection<Product>>();                        
             }
         }
     }
     catch (Exception ex)
     {                
         await new MessageDialog(ex.Message.ToString(), "Load Product").ShowAsync();
     }
     finally
     {
         isResponsed = false;
     }
 }
コード例 #14
0
 public async void GetProductsOfStore(TYPEGET typeGet, TYPE type=0)
 {
     string lastId = "-1";
     int storeId = MediateClass.KiotVM.SelectedStore.StoreId;
     if (typeGet == TYPEGET.MORE)
     {
         if (ProductsOfStore.Count != 0)
         {
             if (type == TYPE.OLD)
                 lastId = ProductsOfStore.Min(x => x.ProductId).ToString();
             else
                 lastId = ProductsOfStore.Max(x => x.ProductId).ToString();
         }
     }            
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"storeId" , storeId.ToString()},
         {"productId" , lastId},
         {"type" , type.ToString()}
     };
     if(lastId != "")
         await PassDataOfStore(typeGet, type, param);
 }
コード例 #15
0
 public async void LoadMoreProduct(TYPEGET type, TYPE isOld=0)
 {
     string lastId = "-1";
     if (type == TYPEGET.MORE)
     {
         if (ProductList.Count != 0)
         {
             if (isOld == TYPE.OLD)
                 lastId = ProductList.Min(x => x.ProductId).ToString();
             else
                 lastId = ProductList.Max(x => x.ProductId).ToString();
         }
     }            
     IDictionary<string, string> param = new Dictionary<string, string>
     {
         {"id" , lastId},
         {"type" , isOld.ToString()}
     };
     await SendData(type, isOld, param);         
 }