Beispiel #1
0
        public static async Task <ContentAndHeads> GetHistOrdersToIDAsync(int statusID, int currentPage, int countItems)
        {
            string expandList   = ExpandList.OrderCustomer + "," + ExpandList.OrderSum + "," + ExpandList.OrderPositionsCount;
            string advancedSort = string.Format(AdvancedSort.ProductToListCategoryIDAndSort, paramSort, desc);
            string url          = WebRequestUtils.GetUrl(Constants.PathToOrders, expandList, null, advancedSort, currentPage, countItems);

            if (statusID != -1)
            {
                string data = "&statuses= " + statusID;
                url += data;
            }

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "GET", null);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                return(null);
            }

            List <Order> Order = JsonConvert.DeserializeObject <List <Order> >(contentAndHeads.Content[0]);

            contentAndHeads.ContentList = Order;

            return(contentAndHeads);
        }
Beispiel #2
0
        public static async Task <List <Basket> > GetProductInBasketAsync(bool isDeleteNoExist = false)
        {
            string          expandList      = ExpandList.BasketProductName + "," + ExpandList.BasketSizeName;
            string          url             = WebRequestUtils.GetUrl(Constants.PathToBasket, expandList, "", 1, 500);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            List <Basket> basketList = new List <Basket> ();

            if (contentAndHeads == null)
            {
                return(basketList);
            }

            basketList = JsonConvert.DeserializeObject <List <Basket> >(contentAndHeads.Content[0]);
            //**************			//basketList = await AddProductInfoAsync (basketList, isDeleteNoExist);

            if (User.Singleton != null)
            {
                User.Singleton.BasketList.Clear();
                User.Singleton.BasketList.AddRange(basketList);
                if (OnePage.topView != null)
                {
                    OnePage.redirectApp.SetStatusBasket(PageName.Basket);
                }
            }

            return(basketList);
        }
Beispiel #3
0
        public static async Task <ContentAndHeads <OrderPosition> > GetOrderPositionAsync(int orderID, int currentPage, int countItems)
        {
            string path = string.Format(Constants.PathToOrderPosition, orderID);
            string url  = WebRequestUtils.GetUrl(path, currentPage, countItems);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                return(null);
            }

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = new List <Product>();

            List <OrderPosition> orderPositionList = JsonConvert.DeserializeObject <List <OrderPosition> > (json);

            ContentAndHeads <OrderPosition> ContentList = new ContentAndHeads <OrderPosition> {
                countPage   = contentAndHeads.countPage,
                currentPage = contentAndHeads.currentPage,
                ContentList = orderPositionList
            };

            return(ContentList);
        }
Beispiel #4
0
        private async void ShowProductAsync(string textSearch)
        {
            Content = scrollMain;
            // Усыпить поток
            await Task.Delay(countSecond * 1000).ConfigureAwait(true);

            DateTime newDate        = DateTime.Now;
            TimeSpan differenceTime = newDate - oldDate;

            if (differenceTime.Seconds < countSecond)
            {
                return;
            }

            if (string.IsNullOrEmpty(textSearch))
            {
                productsListTemplate.IsVisible = false;
                return;
            }
            else
            {
                productsListTemplate.IsVisible = true;
            }

            List <Product> productsList = null;

            Content = indicator;

            Regex rxNums = new Regex(@"^\d+$");              // любые цифры

            if (rxNums.IsMatch(textSearch))
            {
                try {
                    productsList = await Product.GetProductsByArticleAsync(textSearch);
                } catch (Exception) {
                    eventRefresh  = null;
                    eventRefresh += (sender, e) => {
                        Button content = sender as Button;
                        content.IsEnabled = false;
                        ShowProductAsync(textSearch);
                    };
                    Content = OnePage.mainPage.ShowMessageError(eventRefresh);
                    return;
                }
            }
            Content = scrollMain;

            if (productsList != null && productsList.Count > 0)
            {
                productsListTemplate.ShowProducts(productsList);
                return;
            }

            string advancedFilter = string.Format(AdvancedFiltersList.ProductToName, textSearch);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter);

            productsListTemplate.CurrentPage = 1;
            productsListTemplate.ShowProducts(textSearch, url);
        }
Beispiel #5
0
        //public static List<Category> GetCategoriesByID(int id)
        //{
        //	string advancedFilter = string.Format(AdvancedFiltersList.CategoriesToParentID, id);
        //	string expandList = ExpandList.CategoriesDescription;
        //	string url = WebRequestUtils.GetUrl (Constants.UrlCategories, expandList, advancedFilter);

        //	List<string> jsonsList = WebRequestUtils.GetJsonsAllPage (url);
        //	List<Category> categoriesList = new List<Category>();

        //	if (jsonsList != null)
        //		foreach (var item in jsonsList) {
        //			categoriesList.AddRange (JsonConvert.DeserializeObject<List<Category>> (item));
        //		}
        //	return categoriesList;
        //}

        public static async Task <List <Category> > GetCategoriesByIDAsync(int id, bool isChildren = false)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.CategoriesToParentID, id);
            string expandList     = ExpandList.CategoriesDescription;

            if (isChildren)
            {
                expandList += "," + ExpandList.CategoriesChildren;
            }
            string url = WebRequestUtils.GetUrl(Constants.UrlCategories, expandList, advancedFilter);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonsAndHeadsAllPageAsync(url);

            List <string>   jsonsList      = contentAndHeads.Content;
            List <Category> categoriesList = new List <Category>();

            if (jsonsList != null)
            {
                foreach (var item in jsonsList)
                {
                    categoriesList.AddRange(JsonConvert.DeserializeObject <List <Category> > (item));
                }
            }
            foreach (var cat in categoriesList)
            {
                cat.Children.RemoveAll(g => g.Status == 0);
            }
            return(categoriesList);
        }
Beispiel #6
0
        //public static ContentAndHeads GetProductsByCategoryID(int[] catogoriesIDList, int currentPage, int countItems)
        //{
        //	string strCategoryID = string.Join (",", catogoriesIDList);
        //	string advancedFilter = string.Format(AdvancedFiltersList.ProductToListCategoryID, strCategoryID);
        //	string expandList = ExpandList.ProductsDescription;
        //	string url = WebRequestUtils.GetUrl (Constants.UrlProducts, expandList, advancedFilter, currentPage, countItems);

        //	ContentAndHeads contentAndHeads = WebRequestUtils.GetJsonAndHeads (url);

        //	string json = ContentAndHeads.Content[0];
        //	ContentAndHeads.productsList = new List<Product>();
        //	ContentAndHeads.productsList.AddRange (JsonConvert.DeserializeObject<List<Product>> (json));

        //	return ContentAndHeads;
        //}

        public static string GetUrlByCategoryIDAsync(int[] catogoriesIDList)
        {
            string strCategoryID  = string.Join(",", catogoriesIDList);
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToListCategoryID, strCategoryID);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;

            return(WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter));
        }
Beispiel #7
0
        public static async Task <List <Delivery> > GetDeliveryList()
        {
            string url = WebRequestUtils.GetUrl(Constants.PathToListDelivery);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            string          json         = contentAndHeads.Content[0];
            List <Delivery> deliveryList = new List <Delivery> ();

            deliveryList.AddRange(JsonConvert.DeserializeObject <List <Delivery> > (json));

            return(deliveryList);
        }
Beispiel #8
0
        public static async Task <ContentAndHeads> Registration(User user)
        {
            string json     = JsonConvert.SerializeObject(user);
            string postData = "data=" + json;

            string          url             = WebRequestUtils.GetUrl(Constants.PathToregistration);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", postData);

            //if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            //	throw new Exception ();

            //await Task.Delay(1000).ConfigureAwait(true);
            return(contentAndHeads);
        }
Beispiel #9
0
        public static string GetUrlByCategoryIDAsync(int[] catogoriesIDList, FilterParam paramForCheck)
        {
            if (paramForCheck == null)
            {
                return(Product.GetUrlByCategoryIDAsync(catogoriesIDList));
            }
            string strCategoryID        = string.Join(",", catogoriesIDList);
            string formatAdvancedFilter = string.Format(AdvancedFiltersList.ProductToListCategoryIDAndSortToProductDescrioption);

            formatAdvancedFilter += "," + AdvancedFiltersList.ProductToListFilterProductsQuantity;
            formatAdvancedFilter += "," + string.Format(AdvancedFiltersList.ProductToListFilterCategories, strCategoryID);

            if (paramForCheck.Sizes != null && paramForCheck.Sizes.Length > 0)
            {
                string strSizes = string.Join(",", paramForCheck.Sizes);
                formatAdvancedFilter += "," + string.Format(AdvancedFiltersList.ProductToListFilterSizes, strSizes);
            }
            if (paramForCheck.PriceBegin != 0)
            {
                formatAdvancedFilter += "," + string.Format(AdvancedFiltersList.ProductToListFilterPriceBegin, paramForCheck.PriceBegin);
            }
            if (paramForCheck.PriceEnd != 0)
            {
                formatAdvancedFilter += "," + string.Format(AdvancedFiltersList.ProductToListFilterPriceEnd, paramForCheck.PriceEnd);
            }

            formatAdvancedFilter = "[" + formatAdvancedFilter + "]&distinct=1";

            string advancedSort = null;

            if (paramForCheck.paramForSort != null)
            {
                string desc = paramForCheck.paramForSort.IsDesc ? "desc" : "asc";
                if (paramForCheck.paramForSort.FieldSort == ProductsSort.products_name)
                {
                    advancedSort = string.Format(AdvancedSort.ProductToListCategoryIDAndSortToProductDescrioption,
                                                 paramForCheck.paramForSort.FieldSort, desc);
                }
                else
                {
                    advancedSort = string.Format(AdvancedSort.ProductToListCategoryIDAndSort, paramForCheck.paramForSort.FieldSort, desc);
                }
            }

            string expandList = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;

            return(WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, formatAdvancedFilter, advancedSort));
        }
Beispiel #10
0
        public static async Task <ContentAndHeads> ReseltPasswordAsync(string email)
        {
            string          postData        = System.Net.WebUtility.UrlEncode("eMail") + "=" + System.Net.WebUtility.UrlEncode(email) + "&";
            string          url             = WebRequestUtils.GetUrl(Constants.PathToPasswordReset);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", postData);

//			if (ContentAndHeads == null || ContentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
//				return null;
//				throw new Exception ();

            return(contentAndHeads);
//			if (ContentAndHeads == null || ContentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
//				return false;
//
//			return true;
        }
Beispiel #11
0
        public static async Task <User> GetPersonalData()
        {
            string          url             = WebRequestUtils.GetUrl(Constants.PathToPersonalData);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "GET", null);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                throw new Exception();
            }
//				return null;

            string json = contentAndHeads.Content[0];
            User   user = JsonConvert.DeserializeObject <User> (json);

            return(user);
        }
Beispiel #12
0
        public static async Task <List <Product> > GetProductsByIDsListAsync(int[] productIDsList)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToID, string.Join(", ", productIDsList));
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = new List <Product>();

            List <Product> product = JsonConvert.DeserializeObject <List <Product> >(json);

            return(product);
        }
Beispiel #13
0
        public static async Task <List <Product> > GetProductsByNameAsync(string productName, int currentPage, int countItems)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToName, productName);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter, currentPage, countItems);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = new List <Product>();

            List <Product> product = JsonConvert.DeserializeObject <List <Product> >(json);

            return(product);
        }
Beispiel #14
0
        public static async Task <List <Order> > GetHistOrdersAsync()
        {
            string expandList = ExpandList.OrderCustomer + "," + ExpandList.OrderSum;
            string url        = WebRequestUtils.GetUrl(Constants.PathToOrders, expandList, null);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "GET", null);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                return(null);
            }

            List <Order> Order = JsonConvert.DeserializeObject <List <Order> >(contentAndHeads.Content[0]);

            return(Order);
        }
Beispiel #15
0
        public static async Task <ContentAndHeads> PushToBasketAsync(Basket basket)
        {
            string url = WebRequestUtils.GetUrl(Constants.PathToBasketAdd);
            string formatData;
            string postData;

            if (basket.SizeValueId == null || basket.SizeValueId == 0)
            {
                formatData = @"data={{
		            ""products_id"": ""{0}"",
					""customers_basket_quantity"": ""{1}"",
					""comment"": ""{2}"" }}"                    ;
                postData   = string.Format(formatData, basket.ProductID, basket.Quantity, null);
            }
            else
            {
                formatData = @"data={{
		            ""products_id"": ""{0}"",
		            ""attributes"": {{ ""1"": {1} }},
					""customers_basket_quantity"": ""{2}"",
					""comment"": ""{3}"" }}"                    ;
                postData   = string.Format(formatData, basket.ProductID, basket.SizeValueId, basket.Quantity, null);
            }
            //postData = "data=" + postData;

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", postData);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                throw new Exception();
            }

            if (User.Singleton != null)
            {
                Basket basketUser = User.Singleton.BasketList.SingleOrDefault(g => g.Id == basket.Id);
                if (basketUser != null)
                {
                    basketUser.Quantity += basket.Quantity;
                }
                else
                {
                    User.Singleton.BasketList.Add(basket);
                }
                //				OnePage.redirectApp.SetStatusBasket (PageName.Basket);
            }
            return(contentAndHeads);
        }
Beispiel #16
0
        public static async Task <List <SizeArticle> > GetSizeArticleAsync()
        {
            string          url             = WebRequestUtils.GetUrl(Constants.PathToSizeArticle);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                throw new Exception();
            }

            string             json            = contentAndHeads.Content[0];
            List <SizeArticle> sizeArticleList = new List <SizeArticle>();

            sizeArticleList.AddRange(JsonConvert.DeserializeObject <List <SizeArticle> > (json));

            return(sizeArticleList);
        }
Beispiel #17
0
        public static async Task GetTreeCategoriesAsync(Category category, List <int> categoriesIDList, CancellationTokenSource _cancellationTokenSource)
        {
            if (!category.Children.Any(g => g.Children != null))
            {
                string advancedFilter = string.Format(AdvancedFiltersList.CategoriesToParentID, category.ID);
                string expandList     = ExpandList.CategoriesDescription + "," + ExpandList.CategoriesChildren;
                string url            = WebRequestUtils.GetUrl(Constants.UrlCategories, expandList, advancedFilter);

                ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonsAndHeadsAllPageAsync(url);

                if (contentAndHeads == null)
                {
                    return;
                }

                List <string> jsonsList = contentAndHeads.Content;
                category.Children = new List <Category>();

                foreach (string item in jsonsList)
                {
                    List <Category> items = JsonConvert.DeserializeObject <List <Category> >(item);
                    category.Children.AddRange(items);
                }
                foreach (var cat in category.Children)
                {
                    cat.Children.RemoveAll(g => g.Status == 0);
                }
            }
            foreach (Category categoryItem in category.Children)
            {
                categoriesIDList.Add(categoryItem.ID);
            }
            foreach (Category cat in category.Children)
            {
                if (_cancellationTokenSource != null && _cancellationTokenSource.IsCancellationRequested)
                {
                    //_cancellationTokenSource = new CancellationTokenSource ();
                    return;
                }
                if (cat.Children != null && cat.Children.Count != 0)
                {
                    await GetTreeCategoriesAsync(cat, categoriesIDList, _cancellationTokenSource);
                }
            }
        }
Beispiel #18
0
        //public static Product GetProductsByID(int productID)
        //{
        //	string advancedFilter = string.Format(AdvancedFiltersList.ProductToID, productID);
        //	string expandList = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule;
        //	string url = WebRequestUtils.GetUrl (Constants.UrlProducts, expandList, advancedFilter);

        //	ContentAndHeads contentAndHeads = WebRequestUtils.GetJsonAndHeads (url);
        //	if (ContentAndHeads == null)
        //		return null;
        //	string json = ContentAndHeads.Content[0];
        //	ContentAndHeads.productsList = new List<Product>();

        //	List<Product> product = JsonConvert.DeserializeObject<List<Product>> (json);
        //	return product[0];
        //}



        public static async Task <ContentAndHeads> GetProductsByIDToBasketAsync(int productID)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToID, productID);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, isCancelable : true);

            if (contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK || contentAndHeads.Content == null || contentAndHeads.Content.Count == 0)
            {
                return(contentAndHeads);
            }

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = JsonConvert.DeserializeObject <List <Product> >(json);
            return(contentAndHeads);
        }
Beispiel #19
0
        public static async Task <int> GetCountProductByStatusAsync(int id)
        {
            string path = string.Format(Constants.PathToOrderCountStatus, id);
            string url  = WebRequestUtils.GetUrl(path);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                return(0);
            }

            int result;

            int.TryParse(contentAndHeads.Content [0], out result);

            return(result);
        }
Beispiel #20
0
        public static async Task <List <Zone> > GetZoneAndCountry()
        {
            string expandList = ExpandList.ZoneCountry;
            string url        = WebRequestUtils.GetUrl(Constants.PathToZone, expandList, null);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonsAndHeadsAllPageAsync(url);

            List <Zone> zoneList = new List <Zone> ();

            if (contentAndHeads.Content != null)
            {
                foreach (string json in contentAndHeads.Content)
                {
                    zoneList.AddRange(JsonConvert.DeserializeObject <List <Zone> > (json));
                }
            }
            return(zoneList);
        }
Beispiel #21
0
        public static async Task <bool> LoginAsync(string email, string password)
        {
//			email = "*****@*****.**";
//			password = "******";
            Dictionary <string, string> data = new Dictionary <string, string> ();

            data.Add("email", email);
            data.Add("password", password);
            string postData = "";

            if (data != null)
            {
                foreach (string key in data.Keys)
                {
                    postData += System.Net.WebUtility.UrlEncode(key) + "="
                                + System.Net.WebUtility.UrlEncode(data [key]) + "&";
                }
            }
            string          url             = WebRequestUtils.GetUrl(Constants.PathToLogin);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", postData);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                return(false);
            }

            JObject results = JObject.Parse(contentAndHeads.Content[0]);

            if (user == null)
            {
                user = new User();
            }
            user.Id       = (int)results["id"];
            user.Email    = email;
            user.Password = password;
            user.HashKey  = (string)results["key"];

            User userAddress = await User.GetPersonalData();

            user.Address = userAddress.Address;
            await User.LoadBasket();

            return(true);
        }
Beispiel #22
0
        public static async Task <List <OrderStatus> > GetOrderStatusListAsync()
        {
            string url = WebRequestUtils.GetUrl(Constants.PathToOrderStatus);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                return(null);
            }

            List <OrderStatus> orderStatusList = JsonConvert.DeserializeObject <List <OrderStatus> >(contentAndHeads.Content[0]);

            foreach (OrderStatus orderStatus in orderStatusList)
            {
                orderStatus.Count = await GetCountProductByStatusAsync(orderStatus.Id);
            }
            return(orderStatusList);
        }
Beispiel #23
0
        public static async Task <List <Product> > GetProductsByArticleAsync(string productArticle)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToArticle, productArticle);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                throw new Exception();
            }

            string         json         = contentAndHeads.Content[0];
            List <Product> productsList = new List <Product>();

            productsList.AddRange(JsonConvert.DeserializeObject <List <Product> >(json));

            return(productsList);
        }
Beispiel #24
0
        public static async Task <bool> SavePersonalData(User user)
        {
            string url = WebRequestUtils.GetUrl(Constants.PathToPersonalData);

            string json = JsonConvert.SerializeObject(user, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });
            //json = json.Replace ("\"defaultAddress\":", "\"address\":");
            string postData = "data=" + json;

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "PUT", postData);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                throw new Exception();
            }
//				return false;

            return(true);
        }
Beispiel #25
0
        public static async Task <List <Product> > GetProductsNoveltyListAsync(int count)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToListSort, "products_date_added", "desc");
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter, 10, count);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                return(null);
            }

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = new List <Product>();

            List <Product> product = JsonConvert.DeserializeObject <List <Product> >(json);

            return(product);
        }
Beispiel #26
0
        public static async Task <ContentAndHeads <Coupon> > GetProductsByIDAsync(string textCoupon)
        {
            string url = string.Format(Constants.PathToCoupon, textCoupon);

            url = WebRequestUtils.GetUrl(url);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            ContentAndHeads <Coupon> result = new ContentAndHeads <Coupon>();

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                result.MessageError = contentAndHeads.serverException.Message;
            }
            else
            {
                string json = contentAndHeads.Content[0];
                result.ContentList = new List <Coupon>();
                result.ContentList.Add(JsonConvert.DeserializeObject <Coupon>(json));
            }
            return(result);
        }
Beispiel #27
0
        public static async Task <ContentAndHeads> GetProductsByCategoryIDAsync(int[] catogoriesIDList, int currentPage, int countItems)
        {
            string strCategoryID  = string.Join(",", catogoriesIDList);
            string advancedFilter = string.Format(AdvancedFiltersList.ProductToListCategoryID, strCategoryID);
            string expandList     = ExpandList.ProductsAttributesFullInfo + "," + ExpandList.ProductsDescription + "," + ExpandList.ProductsSchedule + "," + ExpandList.ProductsExpress;
            string url            = WebRequestUtils.GetUrl(Constants.UrlProducts, expandList, advancedFilter, currentPage, countItems);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                return(contentAndHeads);
            }

            string json = contentAndHeads.Content[0];

            contentAndHeads.productsList = new List <Product>();
            contentAndHeads.productsList.AddRange(JsonConvert.DeserializeObject <List <Product> > (json));

            return(contentAndHeads);
        }
Beispiel #28
0
        public static async Task <Order> OrderFormBasket(int delivery, string comment, string cuoponCode)
        {
            string expandList = ExpandList.OrderBookkeepingID + "," + ExpandList.OrderShippingForCustomer + "," + ExpandList.OrdersProductsWithAttributes;
            string url        = WebRequestUtils.GetUrl(Constants.PathToOrderFromBasket, expandList, null);

            string data;

            if (string.IsNullOrEmpty(cuoponCode))
            {
                data = string.Format(@"data={{
		            ""orderingCommentKey"": ""{0}"",
		            ""orderingShippingKey"": {1},
					""referrerURL"": ""android_app"" }}"                    , comment, delivery);
            }
            else
            {
                data = string.Format(@"data={{
		            ""orderingCommentKey"": ""{0}"",
		            ""orderingShippingKey"": {1},
					""couponCode"": ""{2}"",
					""referrerURL"": ""android_app"" }}"                    , comment, delivery, cuoponCode);
            }
            //select * from orders where customers_referer_url = "android_app"



            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", data);

            if (contentAndHeads.requestStatus != HttpStatusCode.OK)
            {
                return(null);
            }

            Order order = JsonConvert.DeserializeObject <Order>(contentAndHeads.Content[0]);

            order.Total = order.OrdersProducts.Sum(g => g.Price);
            order.DeliveryForCustomer.Value = order.DeliveryForCustomer.Value ?? 0;
            return(order);
        }
Beispiel #29
0
        public static async Task <Category> GetegoryByIDAsync(int id, bool isChildren = false)
        {
            string advancedFilter = string.Format(AdvancedFiltersList.CategoriesToID, id);
            string expandList     = ExpandList.CategoriesDescription;

            if (isChildren)
            {
                expandList += "," + ExpandList.CategoriesChildren;
            }
            string url = WebRequestUtils.GetUrl(Constants.UrlCategories, expandList, advancedFilter);

            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                throw new Exception();
            }

            string   json     = contentAndHeads.Content[0];
            Category category = JsonConvert.DeserializeObject <List <Category> > (json)[0];

            return(category);
        }
Beispiel #30
0
        public static async Task <bool> Registration(string login, string password)
        {
            Dictionary <string, string> data = new Dictionary <string, string> ();

            data.Add("customers_email_address", login);
            data.Add("customers_password", password);


            string json     = JsonConvert.SerializeObject(data);
            string postData = "data=" + json;

            string          url             = WebRequestUtils.GetUrl(Constants.PathToregistration);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", postData);

            if (contentAndHeads == null || contentAndHeads.requestStatus != System.Net.HttpStatusCode.OK)
            {
                throw new Exception();
            }
//				return false;

            //await Task.Delay(1000).ConfigureAwait(true);
            return(true);
        }