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); }
void SetPagination(Pagination pagination, ContentAndHeads contentAndHeads) { pagination.CurrentPage = contentAndHeads.currentPage; pagination.CountPage = contentAndHeads.countPage; pagination.Show(); pagination.tapGestureRecognizer.Tapped += ClickPage; }
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); }
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); }
//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); }
private void ShowProducts(ContentAndHeads contentAndHeads) { List <Product> productsList; productsList = contentAndHeads.productsList; if (productsList != null && productsList.Count > 0) { productsListTemplate.ShowProducts(productsList); } }
public async void ShowProducts(string url) { Content = layoutMain; indicator.IsVisible = true; layoutProductGrid.IsVisible = false; Url = url; try { contentAndHeads1 = await Product.GetProductsAsync(url, CurrentPage, XPagination.CountProduct); } catch (Exception ex) { eventRefresh = null; eventRefresh += (sender, e) => { Button content = sender as Button; content.IsEnabled = false; ShowProducts(url); }; Content = OnePage.mainPage.ShowMessageError(eventRefresh); return; } if (contentAndHeads1.exceptionStatus == System.Net.WebExceptionStatus.RequestCanceled) { return; } List <Product> productsList = contentAndHeads1.productsList; if (productsList == null || productsList.Count == 0) { Content = new Label { HorizontalOptions = LayoutOptions.Center, Text = "Количество товаро - 0" }; } if (contentAndHeads1.countPage > 1) { SetPagination(paginationBegin, contentAndHeads1); SetPagination(paginationEnd, contentAndHeads1); paginationBegin.IsVisible = true; paginationEnd.IsVisible = true; } else { paginationBegin.IsVisible = false; paginationEnd.IsVisible = false; } productsList = contentAndHeads1.productsList; ShowGrid(gridVerticalProductsList, productsList, true, 2); }
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); }
public static async void SendLog(Dictionary <string, string> appsLog) { string s = DictionaryToPostString(appsLog); string url = Constants.PathToLog; ContentAndHeads contentAndHeads = null; contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", s, true); if (contentAndHeads.requestStatus != HttpStatusCode.OK && contentAndHeads.requestStatus != HttpStatusCode.Created) { throw new Exception(); } }
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); }
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; }
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); }
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); }
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); }
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); }
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); }
public static async Task <ContentAndHeads> GetProductsAsync(string url, int currentPage, int countItems) { url = WebRequestUtils.GetUrlPage(url, currentPage, countItems); ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, isCancelable : true, isCatalog : true); if (contentAndHeads.exceptionStatus == System.Net.WebExceptionStatus.RequestCanceled) { return(contentAndHeads); } string json = contentAndHeads.Content[0]; contentAndHeads.productsList = new List <Product>(); contentAndHeads.productsList.AddRange(JsonConvert.DeserializeObject <List <Product> >(json)); return(contentAndHeads); }
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); }
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); } } }
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); }
//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); }
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); }
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); }
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); }
public static async Task <List <Banner> > GetProductsByIDAsync() { string url = BannerConstant.Url + string.Format(BannerConstant.BanersToCoeffCList, BannerConstant.BannerGroup, SizeCoefficient); ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, isCancelable : true, isBanner : true); if (contentAndHeads.Content == null || contentAndHeads.Content.Count == 0) { return(null); } string json = contentAndHeads.Content[0]; List <Banner> entity = JsonConvert.DeserializeObject <List <Banner> >(json); if (entity == null || entity.Count == 0) { return(null); } return(entity); }
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); }
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); }
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); }
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); }
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); }