Example #1
0
        public async Task GetNewProductList()
        {
            try
            {
                var result = await GetProductByHandler("nouveaux-produits-recemment-ajoutes");

                List <CollectionProductListDataProducts> data = new List <CollectionProductListDataProducts>();
                foreach (var item in result)
                {
                    ObservableCollection <CollectionProductListDataEdge> req = new ObservableCollection <CollectionProductListDataEdge>();
                    foreach (var val in item.edges)
                    {
                        CollectionProductListDataEdge d1 = new CollectionProductListDataEdge
                        {
                            cursor = val.cursor,
                            node   = val.node
                        };
                        req.Add(d1);
                        if (req.Count == 3)
                        {
                            break;
                        }
                    }
                    data.Add(new CollectionProductListDataProducts
                    {
                        edges    = req,
                        pageInfo = item.pageInfo
                    });
                }
                NewArrivalList = new ObservableCollection <CollectionProductListDataProducts>(data);
            }
            catch (Exception ex)
            {
                UserDialogs.Instance.Alert(ex.Message.ToString());
            }
        }
 public async Task InitializeData(CollectionProductListDataEdge catagoriesByListData)
 {
     try
     {
         SelectedNode = null;
         CarouselList.Clear();
         _collectionListEdge = catagoriesByListData;
         CarouselList        = new ObservableCollection <String>();
         foreach (var item in catagoriesByListData.node.images.edges)
         {
             CarouselList.Add(item.node.originalSrc);
         }
         RaisePropertyChanged(nameof(CarouselList));
         Title       = catagoriesByListData.node.title;
         Price       = catagoriesByListData.node.variants.edges[0].node.price;
         Description = catagoriesByListData.node?.description;
         Counter     = 1;
         TextInfo ti = CultureInfo.CurrentCulture.TextInfo;
         ListOfAttributes = new ObservableCollection <CollectionFilterModel>();
         try
         {
             foreach (var varient in _collectionListEdge.node.variants.edges)
             {
                 foreach (var option in varient.node.selectedOptions)
                 {
                     bool i    = false;
                     var  item = new Data.Models.Common.Data();
                     if (!i)
                     {
                         item.IsSelected = true;
                         item.BorderCol  = "Black";
                     }
                     else
                     {
                         item.IsSelected = false;
                         item.BorderCol  = "White";
                     }
                     if (ListOfAttributes.Any(s => s.AttributeName == option.name))
                     {
                         //Available
                         var findattribute = ListOfAttributes.FirstOrDefault(s => s.AttributeName == option.name);
                         if (!findattribute.datas.Any(s => s.VarientValue == option.value))
                         {
                             item.VarientId = varient.node.id; item.VarientName = option.name; item.VarientValue = option.value;
                             findattribute.datas.Add(item);
                         }
                     }
                     else
                     {
                         //not available
                         CollectionFilterModel datas = new CollectionFilterModel();
                         datas.AttributeName = option.name;
                         datas.datas         = new List <Data.Models.Common.Data>();
                         item.VarientId      = varient.node.id; item.VarientName = option.name; item.VarientValue = option.value;
                         datas.datas.Add(item);
                         ListOfAttributes.Add(datas);
                     }
                 }
             }
             if (ListOfAttributes != null)
             {
                 for (int i = 0; i < ListOfAttributes.Count; i++)
                 {
                     if (ListOfAttributes[i].datas != null)
                     {
                         SelectedNode = new CollectionProductListDataNode2();
                         SelectedNode = _collectionListEdge.node.variants.edges[0].node;
                         ListOfAttributes[i].datas[0].IsSelected = true;
                         ListOfAttributes[i].datas[0].BorderCol  = "Black";
                     }
                 }
             }
         }
         catch (Exception ex)
         {
             ShowAlert(ex.Message);
         }
     }
     catch (Exception ex)
     {
         ex.Message.ToString();
     }
 }