Esempio n. 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);
        }
Esempio n. 2
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);
        }
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        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();
            }
        }
Esempio n. 6
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);
        }
Esempio n. 7
0
        //public static List<AppsLog> GetLog(DateTime dateBegin, DateTime dateEnd, string exceptions)
        //{
        //	string dates = string.Format("[\"{0}\", \"{1}\"]",dateBegin.ToString("yyyy-MM-dd"), dateEnd.ToString("yyyy-MM-dd"));
        //	Dictionary<string, string> arrParam = new Dictionary<string, string> {
        //		{"dates", dates },
        //		{"exceptions", exceptions }
        //	};
        //	string url = WebRequestUtils.GetPathToAddParam(Constants.PathToLog, arrParam);
        //	ContentAndHeads contentAndHeads = WebRequestUtils.GetJsonAndHeads (url);

        //	string json = contentAndHeads.Content[0];
        //	List<AppsLog> arrLogs = new List<AppsLog>();
        //	arrLogs.AddRange (JsonConvert.DeserializeObject<List<AppsLog>> (json));

        //	return arrLogs;
        //}

        //public static void AddLog(AppsLog log)
        //{
        //	Dictionary<string, string> arrParam = new Dictionary<string, string> {
        //		{"system_name", log.SystemName },
        //		{"device_model", log.DeviceModel },
        //		{"system_version", log.SystemVersion },
        //		{"exception_type", log.ExceptionType },
        //		{"stack_trace", log.StackTrace },
        //		{"message", log.Message },
        //		{"additional_data", log.AdditionalData },
        //	};
        //	string url = Constants.PathToLog;
        //	string data = string.Join ("&", arrParam.Select (x => x.Key + "=" + x.Value));
        //	WebRequestUtils.GetJsonAndHeads (url, "POST", data);
        //}

        public static async void AddLogAsync(AppsLog log)
        {
            Dictionary <string, string> arrParam = new Dictionary <string, string> {
                { "system_name", log.SystemName },
                { "device_model", log.DeviceModel },
                { "system_version", log.SystemVersion },
                { "exception_type", log.ExceptionType },
                { "stack_trace", log.StackTrace },
                { "message", log.Message },
                { "additional_data", log.AdditionalData },
            };
            string url  = Constants.PathToLog;
            string data = string.Join("&", arrParam.Select(x => x.Key + "=" + x.Value));
            await WebRequestUtils.GetJsonAndHeadsAsync(url, "POST", data);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 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;
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }
Esempio n. 14
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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
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);
        }
Esempio n. 17
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);
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
0
        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);
        }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
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);
        }
Esempio n. 26
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);
        }
Esempio n. 27
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);
        }
Esempio n. 28
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);
        }
Esempio n. 29
0
        public static async Task <ContentAndHeads <OrderPosition> > GetOrderPositionAsync(string url, int currentPage, int countItems)
        {
            url = WebRequestUtils.GetUrlPage(url, currentPage, countItems);
            ContentAndHeads contentAndHeads = await WebRequestUtils.GetJsonAndHeadsAsync(url, isCancelable : true, isCatalog : true);

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

            if (contentAndHeads.exceptionStatus == System.Net.WebExceptionStatus.RequestCanceled)
            {
                return(ContentList);
            }

            string json = contentAndHeads.Content[0];

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

            ContentList.ContentList = orderPositionList;

            return(ContentList);
        }
Esempio n. 30
0
        public static async void SendLog(AppsLog appsLog)
        {
            Dictionary <string, string> dicLog = new Dictionary <string, string>()
            {
                { "system_name", appsLog.SystemName },
                { "device_model", appsLog.DeviceModel },
                { "system_version", appsLog.SystemVersion },
                { "exception_type", appsLog.ExceptionType },
                { "stack_trace", appsLog.StackTrace },
                { "message", appsLog.Message },
                { "additional_data", appsLog.AdditionalData },
                { "page_history", appsLog.PageHistory },

                { "app_version", appsLog.AppVersion },
                { "app_function", appsLog.AppFunction },
                { "size_memory", appsLog.SizeMemory },
                { "type_error", appsLog.TypeError },
                { "user_id", appsLog.UserId.ToString() },
                { "user_key", appsLog.UseKey },
                { "url", appsLog.UrlApp },
                { "url_data", appsLog.UrlData },
                { "url_method", appsLog.UrlMethod },
            };

            string data = DictionaryToPostString(dicLog);
            string url  = Constants.PathToLog;

            ContentAndHeads contentAndHeads = null;

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

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