public async static Task <List <UserAddress> > GetUserAddresses(string tokenC) { List <UserAddress> addresses = new List <UserAddress>(); var url = DataRoot.GenerateURL("getUserAddresses"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenC); //var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var dataRoot = JsonConvert.DeserializeObject <DataRoot>(json); addresses = dataRoot.user_addresses as List <UserAddress>; } return(addresses); }
public async static Task <string> DeleteUserAddress(string tokenC, int id) { var rez = ""; var url = DataRoot.GenerateURL("deleteUserAddress"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { id = id }; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenC); var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var userRoot = JsonConvert.DeserializeObject <DataRoot>(json); var result = userRoot.message; rez = result; } return(rez); }
public async static Task <string> ChangeUserPass(string tokenC, string oldPassword, string newPassword) { var rez = ""; var url = DataRoot.GenerateURL("changeUserPass"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { token = tokenC, oldPass = oldPassword, newPass = newPassword }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var userRoot = JsonConvert.DeserializeObject <DataRoot>(json); var result = userRoot.message; rez = result; } return(rez); }
public async static Task <List <Home_Stuff> > GetOtherGoods(string productType) { List <Home_Stuff> products = new List <Home_Stuff>(); var url = DataRoot.GenerateURL("getProducts"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { product_type = productType }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var home_stuffRoot = JsonConvert.DeserializeObject <DataRoot>(json); products = home_stuffRoot.home_stuff as List <Home_Stuff>; } return(products); }
public async static Task <List <AssignedOccasions> > GetAssignedOccasions() { List <AssignedOccasions> products = new List <AssignedOccasions>(); var url = DataRoot.GenerateURL("getAssignedOccasions"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var response = await client.GetAsync(url); var json = await response.Content.ReadAsStringAsync(); var dataRoot = JsonConvert.DeserializeObject <DataRoot>(json); products = dataRoot.assigned_occasions as List <AssignedOccasions>; } return(products); }
//----- Prideta filtracijai public async static Task <List <Flower_Type> > GetFlowerTypes() { List <Flower_Type> flowerTypes = new List <Flower_Type>(); var url = DataRoot.GenerateURL("getTypes"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { flower_type = 1 }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var dataRoot = JsonConvert.DeserializeObject <DataRoot>(json); flowerTypes = dataRoot.flowers_type as List <Flower_Type>; } return(flowerTypes); }
public async static Task <string> GetProductImage(int productId, string productType) { string productImage; var url = DataRoot.GenerateURL("getProductImage"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { id = productId.ToString(), product_type = productType }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var productRoot = JsonConvert.DeserializeObject <DataRoot>(json); productImage = productRoot.product_image; } return(productImage); }
public async static Task <List <object> > AddUserAddress(string tokenC, UserAddress userAddress) { List <object> rez = new List <object>(); var url = DataRoot.GenerateURL("addUserAddress"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { address = userAddress.address, postal_code = userAddress.postal_code, city = userAddress.city, phone_number = userAddress.phone_number, customer_name = userAddress.name }; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenC); var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var userRoot = JsonConvert.DeserializeObject <DataRoot>(json); if (userRoot.last_id != null) { rez.Add("Id"); rez.Add(userRoot.last_id); } else { var result = userRoot.message; rez.Add("Message"); rez.Add(result); } } return(rez); }
public async static Task <List <string> > RegisterUser(string userEmail, string userPassword) { // User user = new User(); List <string> userx = new List <string>(); var url = DataRoot.GenerateURL("register"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { email = userEmail, password = userPassword }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var userRoot = JsonConvert.DeserializeObject <DataRoot>(json); if (userRoot.userToken != null) { // user = userRoot.user_data as User; userx.Add("Token"); userx.Add(userRoot.userToken); } else { userx.Add("Message"); userx.Add(userRoot.message); } } return(userx); }
public async static Task <string> EditUserData(string tokenC, User user) { var rez = ""; var url = DataRoot.GenerateURL("editUser"); //----- // sito reikia nes nera ssl var handler = new HttpClientHandler(); handler.ClientCertificateOptions = ClientCertificateOption.Manual; handler.ServerCertificateCustomValidationCallback = (httpRequestMessage, cert, cetChain, policyErrors) => { return(true); }; //------ using (HttpClient client = new HttpClient(handler)) { var data = new { token = tokenC, address = user.address, postal_code = user.postal_code, name = user.name, phone_number = user.phone_number, discount_code = user.discount_code, city = user.city }; var jsonData = new StringContent(JsonConvert.SerializeObject(data), Encoding.UTF8, "application/json"); var response = await client.PostAsync(url, jsonData); var json = await response.Content.ReadAsStringAsync(); var userRoot = JsonConvert.DeserializeObject <DataRoot>(json); var result = userRoot.message; rez = result; } return(rez); }