public ShopDrugPage() { InitializeComponent(); ProductList.IsVisible = false; searchcartheader.IsVisible = false; cartheader.IsVisible = false; itemList = ""; obj = JArray.Parse(SessionObj.GetItem("product")); var products = obj; foreach (var product in products) { if ((string)product["category"] == "Drug") { SearchList.Add(new SearchCart() { ProdName = (string)product["productname"], Manufacturer = (string)product["manufacturer"], Instock = (string)product["quantity"] + " in stock", }); } //searchlist.Add((string)product["productname"]); } }
protected override async Task OnInitAsync() { var token = await SessionStorage.GetItem <string>("token"); HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token); CurrentUser = await SessionStorage.GetItem <User>("currentUser"); var messages = await HttpClient.GetJsonAsync <IEnumerable <Message> >($"api/Messages/{CurrentUser.UserId}"); Conversations = new Dictionary <User, IList <Message> >(); foreach (var message in messages) { if (message.SenderId == CurrentUser.UserId) { if (!Conversations.ContainsKey(message.Receiver)) { Conversations.Add(message.Receiver, new List <Message>()); } Conversations[message.Receiver].Add(message); } else { if (!Conversations.ContainsKey(message.Sender)) { Conversations.Add(message.Sender, new List <Message>()); } Conversations[message.Sender].Add(message); } } }
protected async override Task OnInitAsync() { GlobalStateChange.StateHasChanged += UserLoggedIn; CurrentUser = await SessionStorage.GetItem <User>("currentUser"); StateHasChanged(); }
public AdListPage() { InitializeComponent(); obj = JArray.Parse(SessionObj.GetItem("ad_list")); lst.ItemsSource = List; lst.SelectedItem = null; // de-select the row var products = obj; foreach (var product in products) { var ProdImg = "noimage.png"; var FileName = (string)product["filename"]; if (FileName.Length > 2) { ProdImg = "http://www.mymedbay.com/larahome/public/products/" + FileName; } var ProdDescription = (string)product["description"]; List.Add(new AddList() { ProdName = (string)product["productname"], Manufacturer = " " + ProdDescription + "\n Posted By: " + (string)product["manufacturer"] + "\n Price: GHS" + (string)product["price"] + "\n Quantity: " + (string)product["quantity"] + "\n Expiring: -" + (string)product["expiring"], Image = ProdImg, Contact = (string)product["tel"] }); //searchlist.Add((string)product["productname"]); } }
protected override async Task OnInitAsync() { CurrentUser = await SessionStorage.GetItem <User>("currentUser"); if (CurrentUser == null) { UriHelper.NavigateTo("/login"); } }
public DealsPage() { InitializeComponent(); System.Diagnostics.Debug.WriteLine("Data :" + SessionObj.GetItem("deal")); obj = JArray.Parse(SessionObj.GetItem("deal")); //clear all list items SessionStorage.GProductId.Clear(); SessionStorage.GProductname.Clear(); SessionStorage.GProductCategory.Clear(); SessionStorage.GProductUnitPrice.Clear(); SessionStorage.GProductDescription.Clear(); SessionStorage.GProductFilename.Clear(); SessionStorage.GProductManufacturer.Clear(); SessionStorage.GProductPurchasedQuantity.Clear(); ProductList.ItemsSource = SearchList; foreach (var product in obj) { System.Diagnostics.Debug.WriteLine("----- :" + (string)product["productname"]); var ProdImg = "noimage.png"; var file = (string)product["filename"]; if (file.Length > 2) { ProdImg = "http://www.mymedbay.com/larahome/public/products/" + file; } SearchList.Add(new DealCart() { ProdName = (string)product["productname"], Manufacturer = (string)product["manufacturer"], Amount = "GHS " + (string)product["price"], Instock = (string)product["quantity"] + " in stock", Image = ProdImg, Id = (string)product["id"], }); //searchlist.Add((string)product["productname"]); } }
public ShopDealPage() { InitializeComponent(); ProductList.IsVisible = false; searchcartheader.IsVisible = false; cartheader.IsVisible = false; itemList = ""; obj = JArray.Parse(SessionObj.GetItem("product")); var products = obj; foreach (var product in products) { SearchList.Add(new SearchCart() { ProdName = (string)product["productname"], Manufacturer = (string)product["manufacturer"], Instock = (string)product["quantity"] + " in stock", }); //searchlist.Add((string)product["productname"]); } for (var i = 0; i < SessionStorage.GProductId.Count; i++) { System.Diagnostics.Debug.WriteLine("SessionStorage.GProductPurchasedQuantity[i]= " + SessionStorage.GProductPurchasedQuantity[i]); System.Diagnostics.Debug.WriteLine("SessionStorage.GProductUnitPrice[i]= " + SessionStorage.GProductUnitPrice[i]); System.Diagnostics.Debug.WriteLine("SessionStorage.GProductFilename[i]= " + SessionStorage.GProductFilename[i]); System.Diagnostics.Debug.WriteLine("SessionStorage.GProductId[i]= " + SessionStorage.GProductId[i]); populate(SessionStorage.GProductname[i], SessionStorage.GProductPurchasedQuantity[i], SessionStorage.GProductUnitPrice[i].ToString(), SessionStorage.GProductFilename[i], SessionStorage.GProductId[i]); } }
public PostNeedPage() { InitializeComponent(); obj = JArray.Parse(SessionObj.GetItem("need")); lst.ItemsSource = List; lst.SelectedItem = null; // de-select the row var products = obj; foreach (var product in products) { List.Add(new NeedList() { ProdName = (string)product["ItemName"] + " :" + (string)product["Quantity"] + "pcs", Tel = (string)product["RequestorTel"], User = (string)product["Username"], }); //searchlist.Add((string)product["productname"]); } }
public HomePage() { InitializeComponent(); if (DateTime.Now.Hour < 12) { Day = "\nGood Morning"; } else if (DateTime.Now.Hour < 17) { Day = "\nGood Afternoon"; } else { Day = "\nGood Evening"; } string Details = Day + "\n" + SessionObj.GetItem("name") + "\n" + "MEDBAY PREFERRED CLIENT " + "\n" + "Last login :"******"\n"; Myname.Text = Details; }
private async void UserLoggedIn(object sender, EventArgs e) { CurrentUser = await SessionStorage.GetItem <User>("currentUser"); StateHasChanged(); }
public Task <string> GetAccessTokenAsync() => _storage.GetItem <string>(AccessTokenKey);
async void Confirm(object sender, EventArgs e) { try { if (location.Text.Length < 5) { await DisplayAlert("Alert", "Enter a valid delivery address", "OK"); return; } if (PayType.Length < 1) { await DisplayAlert("Alert", "Select a payment method", "OK"); return; } BtnConfirm.IsEnabled = false; await Task.Delay(100); var postData = "email=" + SessionObj.GetItem("email").Trim(); postData += "&usertoken=" + SessionObj.GetItem("usertoken").Trim(); postData += "&name=" + SessionObj.GetItem("name"); postData += "&cart=" + SessionObj.GetItem("ProductList"); postData += "&tel=" + SessionObj.GetItem("tel"); postData += "&total=" + SessionObj.GetItem("Total").Trim(); postData += "&paytype=" + PayType.ToString(); postData += "&address=" + location.Text; System.Diagnostics.Debug.WriteLine("PostData :" + postData); BtnConfirm.IsEnabled = false; GetOnlineRequest sendrequest = new GetOnlineRequest(SessionStorage.IPPORT + "orderpayment", "POST", postData); string LoginDetails = sendrequest.GetResponse(); obj = JObject.Parse(LoginDetails); if (obj["success"].ToString() == "0") { //order successful await DisplayAlert("Alert", obj["message"].ToString(), "OK"); SessionStorage.MAINPOPUP = 1; await this.Navigation.PopModalAsync(); return; } else { BtnConfirm.IsEnabled = true; await Task.Delay(100); await DisplayAlert("Alert", "An error has occurred \n" + LoginDetails.ToString(), "OK"); return; } } catch (Exception n) { BtnConfirm.IsEnabled = true; System.Diagnostics.Debug.WriteLine("Exception Caught :" + n.ToString()); await DisplayAlert("Alert", "An error has occured \n Please try again ", "OK"); //return; } }
private async Task BtnConfirm_Clicked(object sender, EventArgs e) { try { byte[] b = System.IO.File.ReadAllBytes(base64); String basestr = Convert.ToBase64String(b); //System.Diagnostics.Debug.WriteLine("base64 " + basestr); if (String.IsNullOrEmpty(itemname.Text)) { await DisplayAlert("Alert", "Item Name input required!", "OK"); return; } else if (String.IsNullOrEmpty(itemquantity.Text)) { await DisplayAlert("Alert", "Quantity input required!", "OK"); return; } else if (String.IsNullOrEmpty(unitprice.Text)) { await DisplayAlert("Alert", "Price input required!", "OK"); return; } else if (category.Items[category.SelectedIndex].Length < 1) { await DisplayAlert("Alert", "Item Category input required!", "OK"); return; } if (String.IsNullOrEmpty(expDate.Date.ToString("dd-MMM-yyyy").Trim())) { await DisplayAlert("Alert", "Expiring Date input required!", "OK"); return; } BtnConfirm.Text = "Please wait..."; BtnConfirm.IsEnabled = false; await Task.Delay(1000); //fullname,telephone,email,country,password,repassword var postData = "productname=" + itemname.Text; postData += "&category=" + category.Items[category.SelectedIndex].ToString(); postData += "&price=" + unitprice.Text; postData += "&quantity=" + itemquantity.Text; postData += "&description=" + itemname.Text; postData += "&manufacturer=" + SessionObj.GetItem("name"); postData += "&expDate=" + expDate.Date.ToString("dd-MMM-yyyy").Trim(); postData += "&photo=" + basestr; postData += "&isFromApi=true"; System.Diagnostics.Debug.WriteLine("PostData" + postData); System.Diagnostics.Debug.WriteLine(SessionStorage.IPPORT + "addproductfromuser"); GetOnlineRequest sendrequest = new GetOnlineRequest(SessionStorage.IPPORT + "addproductfromuser", "POST", postData); string LoginDetails = sendrequest.GetResponse(); Console.WriteLine("Registration response" + LoginDetails); System.Diagnostics.Debug.WriteLine("Registration response" + LoginDetails); obj = JObject.Parse(LoginDetails); //ad ok if (obj["success"].ToString() == "0") { //success await DisplayAlert("Success", obj["message"].ToString(), "OK"); await Navigation.PopModalAsync(); } // failed else { Whenfail(); await Task.Delay(100); await DisplayAlert("Error", obj["message"].ToString(), "OK"); } } catch (Exception f) { Whenfail(); await Task.Delay(100); await DisplayAlert("Error", "This error might be that u haven't filled all required field or you haven't uploaded a valid photo or a server error has occured. Please find below the error details \n (" + f.Message + ")", "OK"); return; } }
private async Task BtnConfirm_Clicked(object sender, EventArgs e) { try { if (String.IsNullOrEmpty(itemname.Text)) { await DisplayAlert("Alert", "Item Name input required!", "OK"); return; } else if (String.IsNullOrEmpty(itemquantity.Text)) { await DisplayAlert("Alert", "Quantity input required!", "OK"); return; } BtnConfirm.Text = "Please wait..."; BtnConfirm.IsEnabled = false; await Task.Delay(1000); //fullname,telephone,email,country,password,repassword var postData = "productname=" + itemname.Text; postData += "&quantity=" + itemquantity.Text; postData += "&Username="******"name"); postData += "&email=" + SessionObj.GetItem("email"); postData += "&tel=" + SessionObj.GetItem("tel"); postData += "&isneedmet=0"; System.Diagnostics.Debug.WriteLine("PostData" + postData); GetOnlineRequest sendrequest = new GetOnlineRequest(SessionStorage.IPPORT + "postneed", "POST", postData); string LoginDetails = sendrequest.GetResponse(); Console.WriteLine("Registration response" + LoginDetails); System.Diagnostics.Debug.WriteLine("Registration response" + LoginDetails); obj = JObject.Parse(LoginDetails); //ad ok if (obj["success"].ToString() == "0") { //success await DisplayAlert("Success", obj["message"].ToString(), "OK"); await Navigation.PopModalAsync(); } // failed else { Whenfail(); await Task.Delay(100); await DisplayAlert("Error", obj["message"].ToString(), "OK"); } } catch (Exception f) { Whenfail(); await Task.Delay(100); await DisplayAlert("Error", f.Message, "OK"); } }
public async Task <string> GetTokenAsync() { return(tokenCache ?? await sessionStorage.GetItem <string>(StorageKey) ?? await localStorage.GetItem <string>(StorageKey)); }