private async void DoneBtn_Clicked(object sender, EventArgs e) { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } var returnMessage = CheckValidations(); if (!string.IsNullOrEmpty(returnMessage)) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(returnMessage)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } try { string phn = "["; phn += phn = "]"; LoggedInUser obj = App.Database.GetLoggedInUser(); await Navigation.PushPopupAsync(new Loader()); string postData = "user_id=" + obj.userId + "&company_name=" + companNameTxt.Text + "&communication_number=" + phn + "&delivery_system=" + delivery + "&country_code=" + countryCode + "&license_number=" + licenceNumberTxt.Text + "&shop_address=" + addressNumberTxt.Text + "&lat=" + Latitude + "&lng=" + Longitude; HttpClient httpClient = new HttpClient(); string boundary = "---8d0f01e6b3b5dafaaadaad"; MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary); try { if (mysfile != null) { var fileContent = new ByteArrayContent(mysfile); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "logo", FileName = "logoShop" + ".png", }; multipartContent.Add(fileContent); } if (mysfileBanner != null) { var fileContentBanner = new ByteArrayContent(mysfileBanner); fileContentBanner.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContentBanner.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "banner", FileName = "bannerShop" + ".png", }; multipartContent.Add(fileContentBanner); } } catch { } HttpResponseMessage response = await httpClient.PostAsync(CommonLib.ws_MainUrl + "shopRegister?" + postData, multipartContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content != null) { mysfile = null; mysfileBanner = null; ShopRegisterResult objData = new ShopRegisterResult(); objData = Newtonsoft.Json.JsonConvert.DeserializeObject <ShopRegisterResult>(content); if (objData.status == 1) { Loader.CloseAllPopup(); // Save data in sqlite for login check LoggedInUser objUser = new LoggedInUser(); objUser.ID = obj.ID; objUser.userId = obj.userId; objUser.fname = obj.fname; objUser.lname = obj.lname; objUser.email = obj.email; objUser.image = ""; objUser.phone = obj.phone; objUser.userType = obj.userType; objUser.country_code = obj.country_code; objUser.is_shop = "1"; App.Database.SaveLoggedInUser(objUser); if (App.Lng == "ar-AE") { await DisplayAlert("", objData.msg_ar, "OK"); } else { await DisplayAlert("", objData.msg_en, "OK"); } App.Current.MainPage = new NavigationPage(new HomeMasterPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } } else { Loader.CloseAllPopup(); await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(response.RequestMessage.ToString())); await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
private async void deliverLbl_Clicked(object sender, EventArgs e) { var ans = await App.Current.MainPage.DisplayAlert("", AppResources.haveyoudelivedrorder, AppResources.yes, AppResources.no); if (ans) { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "order_id=" + id + "&user_id=" + objUser.userId; var result = await CommonLib.SellerOrderAcceptReject(CommonLib.ws_MainUrl + "sellerOrderDeliver?" + postData); if (result.status == 1) { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); await Navigation.PopAsync(); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } }
private async void AddBtn_Clicked(object sender, EventArgs e) { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } var returnMessage = CheckValidations(); if (!string.IsNullOrEmpty(returnMessage)) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(returnMessage)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } try { LoggedInUser obj = App.Database.GetLoggedInUser(); await Navigation.PushPopupAsync(new Loader()); // string postData = "user_id=" + obj.userId + "&name=" + productNameTxt.Text + "&price=" + productPriceTxt.Text + "&description=" + productDetailTxt.Text + "&quantity=" + productquantityTxt.Text + "&prepare_time=" + producttimeTxt.Text + "&is_offer=" + is_offer; string postData = "user_id=" + obj.userId + "&name=" + productNameTxt.Text; HttpClient httpClient = new HttpClient(); string boundary = "---8d0f01e6b3b5dafaaadaad"; MultipartFormDataContent multipartContent = new MultipartFormDataContent(boundary); try { if (mysfile != null) { var fileContent = new ByteArrayContent(mysfile); fileContent.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/octet-stream"); fileContent.Headers.ContentDisposition = new System.Net.Http.Headers.ContentDispositionHeaderValue("form-data") { Name = "images[]", FileName = "userimage" + ".png", }; multipartContent.Add(fileContent); } } catch { } string url = CommonLib.ws_MainUrl + "addProduct?" + postData; HttpResponseMessage response = await httpClient.PostAsync(url, multipartContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content != null) { mysfile = null; AddProductResult objData = new AddProductResult(); objData = Newtonsoft.Json.JsonConvert.DeserializeObject<AddProductResult>(content); if (objData.status == 1) { Loader.CloseAllPopup(); AddAddonsViewModel.productId = objData.data.Product.id; EditProduct.id = ""; // await DisplayAlert("", objData.msg_ar, "OK"); await App.Current.MainPage.Navigation.PushAsync(new AddAddonsPage()); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(objData.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } } else { Loader.CloseAllPopup(); await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage("Upload 1 MB Image")); await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
public async void load() { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "order_id=" + id; var result = await CommonLib.GetCustomerOrderInfo(CommonLib.ws_MainUrl + "getUserOrderInfo?" + postData); if (result.status == 1) { _ptotalPrice = 0; _expandedGroups = new ObservableCollection <CartViewModel>(); var _products = App.Database.GetAllProduct(); foreach (var group in result.data.order.OrderProduct) { _ptotalPrice += Convert.ToDouble(group.price) * Convert.ToDouble(group.quantity); string img = ""; foreach (var food in group.Addon) { if (food.AddonMedia == null) { img = "product_Placeholder.png"; } else { img = string.IsNullOrEmpty(food.AddonMedia.media) ? "product_Placeholder.png" : CommonLib.img_MainUrl + food.AddonMedia.media; } } CartViewModel newGroup = new CartViewModel(group.name, group.quantity, group.price, Convert.ToString(group.id), group.product_id, "", img, ""); foreach (var food in group.Addon) { _ptotalPrice += Convert.ToDouble(food.price) * Convert.ToDouble(food.quantity); newGroup.Add(new CartProduct { Note = (!string.IsNullOrEmpty(food.note)) ? AppResources.noteDetails + ":- " + food.note : "", Name = food.name, AddonCategory = "", AddonId = food.addon_id, AddonPrice = food.price, AddonQty = food.quantity, PSQLId = "", ProductId = food.product_id }); } _expandedGroups.Add(newGroup); } GroupedView.ItemsSource = _expandedGroups; if (_expandedGroups.Count == 0) { emptyCartLbl.IsVisible = true; totalLyt.IsVisible = false; } else { emptyCartLbl.IsVisible = false; totalLyt.IsVisible = true; totalPrice.Text = "Riyal " + _ptotalPrice; } // if (result.data.order.Order.status == "0") { acptBtns.IsVisible = true; statusBtns.IsVisible = false; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status != "0") { acptBtns.IsVisible = false; statusBtns.IsVisible = true; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } // string sts = ""; if (result.data.order.Order.status == "2") { sts = AppResources.Orderrejectedby; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "3") { sts = AppResources.Orderassignedtodriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "-1" || result.data.order.Order.status == "-2" || result.data.order.Order.status == "-3") { sts = AppResources.Ordercancel; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "4") { sts = AppResources.Orderacceptedbydriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false;//true; } if (result.data.order.Order.status == "5") { sts = AppResources.Orderrejectedbydriver; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "6") { sts = AppResources.delivered; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "7") { sts = AppResources.Ordercompleted1; completeLbl.IsVisible = false; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "8") { sts = AppResources.Orderacceptedbyseller; completeLbl.IsVisible = true; deliverLbl.IsVisible = false; } if (result.data.order.Order.status == "9") { sts = AppResources.delivered; if (result.data.order.Order.self_pick == "1") { completeLbl.IsVisible = true; } else { completeLbl.IsVisible = false; } deliverLbl.IsVisible = false; } statusLbl.Text = sts; Loader.CloseAllPopup(); CustomerPhone = result.data.order.Customer.phone; customerName.Text = result.data.order.Customer.first_name + " " + result.data.order.Customer.last_name; customerImage.Source = CommonLib.img_MainUrl + result.data.order.Customer.image; } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
private async void AcceptLbl_Clicked(object sender, EventArgs e) { try { int count = 1; if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); Outer: string postData = "order_id=" + id + "&user_id=" + objUser.userId + "&status=1" + "&attempt=" + count; var result = await CommonLib.SellerOrderAcceptReject(CommonLib.ws_MainUrl + "sellerOrderAction?" + postData); if (result.status == 1) { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); load(); } else if (result.status == 2) { count++; goto Outer; } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); //App.Current.MainPage = new NavigationPage(new HomeMasterPage()); await Navigation.PopAsync(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
public async void loadProduct() { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "user_id=" + objUser.userId; var result = await CommonLib.GetSellerProduct(CommonLib.ws_MainUrl + "getSellerProducts?" + postData); if (result.status == 1) { _expandedGroups = new ObservableCollection <ExpendProductViewModel>(); foreach (var group in result.data.products) { ExpendProductViewModel newGroup = new ExpendProductViewModel(group.Product.name, group.Product.id); foreach (var food in group.addon) { string image = ""; if (food.ProductMedia.Count == 0) { image = "product_Placeholder.png"; } foreach (var img in food.ProductMedia) { image = string.IsNullOrEmpty(img.media) ? "product_Placeholder.png" : CommonLib.img_MainUrl + img.media; break; } string _price = ""; if (food.ProductAddon.price_large != "0.00") { _price = food.ProductAddon.price_large; } if (food.ProductAddon.price_small != "0.00") { _price = food.ProductAddon.price_small; } if (food.ProductAddon.price_medium != "0.00") { _price = food.ProductAddon.price_medium; } string isvisible = "False"; if (Convert.ToInt32(food.ProductAddon.quantity) <= 0) { isvisible = "True"; } newGroup.Add(new ProductPageItem { isvisible = isvisible, category_id = "x " + food.ProductAddon.quantity, user_id = food.ProductAddon.user_id, ProductName = food.ProductAddon.name, ProductId = food.ProductAddon.id, ProductImage = image, ProductPrice = _price, }); } _expandedGroups.Add(newGroup); } productListView.ItemsSource = _expandedGroups; Loader.CloseAllPopup(); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }
private async void delete_Tapped(object sender, EventArgs e) { try { var getBtn = sender as Frame; var aa = getBtn.BindingContext; var ans = await App.Current.MainPage.DisplayAlert("", AppResources.deleteSellerProductMsg, AppResources.yes, AppResources.no); if (ans) { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "id=" + aa + "&user_id=" + objUser.userId; var result = await CommonLib.DeleteCustomerAddress(CommonLib.ws_MainUrl + "deleteProduct?" + postData); if (result.status == 1) { Loader.CloseAllPopup(); loadProduct(); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } } } catch (Exception) { } }
//private async void UploadImg_Tapped(object sender, EventArgs e) //{ // try // { // var action = await App.Current.MainPage.DisplayActionSheet(AppResources.choose_image, AppResources.cancel, null, // AppResources.take_picture, AppResources.choose_from_gallery); // string _selectedColor = string.Empty; // if (action == AppResources.take_picture) // { // await CrossMedia.Current.Initialize(); // if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsPickPhotoSupported) // { // App.Current.MainPage.DisplayAlert("No Camera", "No camera avaialble.", "OK"); // return; // } // if (Device.RuntimePlatform == "iOS") // { // await Task.Delay(1000); // } // var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions // { // Directory = "Sample", // Name = "test.jpg" // }); // if (file == null) // return; // using (var memoryStream = new MemoryStream()) // { // file.GetStream().CopyTo(memoryStream); // var myfile = memoryStream.ToArray(); // mysfile = myfile; // mysfile = await CrossImageResizer.Current.ResizeImageWithAspectRatioAsync(myfile, 500, 500); // file.Dispose(); // } // ProductImg4.Source = ImageSource.FromStream(() => new MemoryStream(mysfile)); // } // if (action == AppResources.choose_from_gallery) // { // await CrossMedia.Current.Initialize(); // if (!CrossMedia.Current.IsPickPhotoSupported) // { // await DisplayAlert("", "Image not support", "OK"); // return; // } // var file = await CrossMedia.Current.PickPhotoAsync(); // if (file != null) // { // using (var memoryStream = new MemoryStream()) // { // file.GetStream().CopyTo(memoryStream); // var myfile = memoryStream.ToArray(); // mysfile = myfile; // mysfile = await CrossImageResizer.Current.ResizeImageWithAspectRatioAsync(myfile, 500, 500); // file.Dispose(); // } // ProductImg4.Source = ImageSource.FromStream(() => new MemoryStream(mysfile)); // } // } // } // catch (Exception ex) // { // } // // imgLyt.Children.Clear(); // //foreach (var item in uploadProductImgs) // //{ // // Image image = new Image() // // { // // Source = item.img, // // Aspect = Aspect.Fill // // }; // // Grid grid = new Grid() // // { // // RowDefinitions = // // { // // new RowDefinition { Height = 80 }, // // }, // // ColumnDefinitions = // // { // // new ColumnDefinition { Width = 80 }, // // } // // }; // // grid.Children.Add(new Frame // // { // // HasShadow = false,Padding=0, // // CornerRadius = 4, // // Content = image // // } // // ,0,0); // // grid.Children.Add(new Image // // { // // Source = "delete_address.png", HeightRequest = 25, WidthRequest = 25,Margin=new Thickness(-28,-55,20,0) // // } // // , 1, 0); // // imgLyt.Children.Add(grid); // //} // //imgLyt.Children.Remove(imgGrid4); // //imgLyt.Children.Add(imgGrid4); //} //private void Offer_Tapped(object sender, EventArgs e) //{ // string path = offers.Source.ToString(); ; // if (path == "File: ico_check.png") // { // offers.Source = "ico_checked.png"; // is_offer = 1; // } // else // { // offers.Source = "ico_check.png"; // is_offer = 0; // } //} public async void load() { try { if (!CommonLib.checkconnection()) { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(AppResources._connection)); await Task.Delay(1000); ShowMessage.CloseAllPopup(); return; } await App.Current.MainPage.Navigation.PushPopupAsync(new Loader()); LoggedInUser objUser = App.Database.GetLoggedInUser(); string postData = "id=" + id; var result = await CommonLib.EditProductDetails(CommonLib.ws_MainUrl + "productDetail?" + postData); if (result.status == 1) { //is_offer =Convert.ToInt32(result.data.product.Product.is_offer); //if (is_offer == 1) //{ // offers.Source = "ico_checked.png"; //} //else //{ // offers.Source = "ico_check.png"; //} productNameTxt.Text = result.data.product.Product.name; //productPriceTxt.Text = result.data.product.Product.price; //productquantityTxt.Text = result.data.product.Product.quantity; //productDetailTxt.Text = result.data.product.Product.description; //producttimeTxt.Text = result.data.product.Product.prepare_time; //string image = ""; //if (result.data.product.ProductMedia.Count == 0) { image = "product_Placeholder.png"; } //foreach (var img in result.data.product.ProductMedia) //{ // image = string.IsNullOrEmpty(img.media) ? "product_Placeholder.png" : CommonLib.img_MainUrl + img.media; break; //} //ProductImg4.Source = image; Loader.CloseAllPopup(); } else { Loader.CloseAllPopup(); if (App.Lng == "ar-AE") { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_ar)); } else { await App.Current.MainPage.Navigation.PushPopupAsync(new ShowMessage(result.msg_en)); } await Task.Delay(1000); ShowMessage.CloseAllPopup(); } } catch (Exception ex) { Loader.CloseAllPopup(); } }