public async void myItems() { try { await CreateItems(Settings.email, Settings.password); await CreateProductImages(Settings.email, Settings.password); var result = from f in productList join s in imageList on f.productNo equals s.productNo into g select new { f.productNo, f.prodCategory, f.prodSubCategory, f.prodPrice, f.prodDescription, f.prodSize, f.prodColour, f.prodBrand, f.prodLocation, f.prodSold, f.prodSellerNo, g.First().prodImageString }; foreach (var e in result) { byte[] imageByte = Convert.FromBase64String(e.prodImageString); ImageSource imgSrc = ImageSource.FromStream(() => new MemoryStream(imageByte)); Image im = new Image(); im.HeightRequest = 500; im.WidthRequest = 400; im.Source = imgSrc; var prodItem = new tblProducts { prodCategory = e.prodCategory, prodSubCategory = e.prodSubCategory, prodPrice = e.prodPrice, prodDescription = e.prodDescription, prodSize = e.prodSize, prodColour = e.prodColour, prodBrand = e.prodBrand, prodLocation = e.prodLocation, prodSold = e.prodSold, prodSellerNo = e.prodSellerNo }; Label ep = new Label(); ep.FontSize = 20; ep.HorizontalOptions = LayoutOptions.StartAndExpand; ep.Text = prodItem.prodDescription.ToString(); itemsStack.Children.Add(ep); } } catch (Exception ex) { await DisplayAlert("Error", "An error has occured, please try again later", "OK"); } }
public async Task <tblProducts> CreateItem(string email, string password) { //var authProvider = new FirebaseAuthProvider(new FirebaseConfig("AIzaSyCpxDUBeaHiEKaNUEyBPgJxjRDAlGtxW1U")); //var data = await authProvider.CreateUserWithEmailAndPasswordAsync(email, password); var db = new FirebaseClient( "https://olive-4a870.firebaseio.com/", new FirebaseOptions { AuthTokenAsyncFactory = () => Task.FromResult(Settings.authToken) }); var dbData = await db .Child("Products") //.Child(data.User.LocalId) .OnceAsync <tblProducts>(); var products = dbData.Where(a => a.Key == productID).ToList(); foreach (var e in products) { e.Object.productNo = e.Key; var json = JsonConvert.SerializeObject(e.Object); var prodObject = JsonConvert.DeserializeObject <tblProducts>(json); productDetails = prodObject; } return(productDetails); }
private void btnAddArticle_Click(object sender, EventArgs e) { tblProducts model = new tblProducts(); try { using (DB db = new DB()) { model.Name = txtAddProductName.Text; model.Description = txtAddProductDescription.Text; model.Price = decimal.Parse(txtAddProductPrice.Text); model.CategoryName = cbAddProductCategory.Text; db.Products.Add(model); db.SaveChanges(); } this.Alert("Article added", Messages.Messages.enmType.Success); //MessageBox.Show("XD", "OK"); } catch (System.Data.Entity.Validation.DbEntityValidationException) { this.Alert("Error", Messages.Messages.enmType.Error); //MessageBox.Show("XD", "FAIL"); } }
public async Task <IActionResult> SaveProduct([FromBody] tblProducts tblProducts) { if (!ModelState.IsValid) { return(await Task.FromResult(BadRequest(ModelState))); } BackgroundJob.Enqueue(() => _service.SaveProduct(tblProducts)); //BackgroundJob.Schedule(() => _service.SaveProduct(tblProducts), DateTime.Now.AddMinutes(30)); //RecurringJob.AddOrUpdate("parent_id", () => _service.SaveProduct(tblProducts), Cron.Minutely()); return(Ok()); }
public async void CreateWishlist() { //var result = new List<tblProducts>(); try { await CreateWishlist(Settings.email, Settings.password); if (hasWishlist == true) { Wishlist.IsVisible = true; NoCasesLabel.IsVisible = false; await CreateItems(Settings.email, Settings.password); await CreateProductImages(Settings.email, Settings.password); var result = from f in productList join s in imageList on f.productNo equals s.productNo into g select new { f.productNo, f.prodCategory, f.prodSubCategory, f.prodPrice, f.prodDescription, f.prodSize, f.prodColour, f.prodBrand, f.prodLocation, f.prodSold, f.prodSellerNo, g.First().prodImageString }; foreach (var e in result) { byte[] imageByte = Convert.FromBase64String(e.prodImageString); ImageSource imgSrc = ImageSource.FromStream(() => new MemoryStream(imageByte)); Image im = new Image(); im.HeightRequest = 500; im.WidthRequest = 400; im.Source = imgSrc; var prodItem = new tblProducts { prodCategory = e.prodCategory, prodSubCategory = e.prodSubCategory, prodPrice = e.prodPrice, prodDescription = e.prodDescription, prodSize = e.prodSize, prodColour = e.prodColour, prodBrand = e.prodBrand, prodLocation = e.prodLocation, prodSold = e.prodSold, prodSellerNo = e.prodSellerNo }; Label ep = new Label(); ep.FontSize = 20; ep.HorizontalOptions = LayoutOptions.StartAndExpand; ep.Text = prodItem.prodDescription.ToString(); Wishlist.Children.Add(ep); } //Wishlist.ItemsSource = data; } else { Wishlist.IsVisible = false; NoCasesLabel.IsVisible = true; } } catch (Exception ex) { throw ex; } }
public async void CreateWishlist() { //var result = new List<tblProducts>(); try { //string str_JSONincident = AppServiceLiveToPhone.GetLiveDBIncidents(Convert.ToInt32(Settings.LiveIpCoID)).Result; //string str_JSONincident = AppServiceLiveToPhone.getLiveDBIncidentsSync(Convert.ToInt32(Settings.LiveIpCoID)).Result; //if (str_JSONincident != "0") //{ // foreach (LiveIncidents item in JsonConvert.DeserializeObject<List<LiveIncidents>>(str_JSONincident)) // { // result.Add( // new MyCases // { // Id = item.IpInID, // Name = "Case No. " + item.IpInID.ToString(), // BackgroundColor = Color.FromHex("#00162E"), // BackgroundImage = "", // Icon = GrialShapesFont.Event, // Badge = 2, // CaseInfo = item.IpInDateAdded.ToString() // }); // } //hasWishlist = true; //} //else //{ // hasWishlist = false; //} await CreateWishlist(Settings.email, Settings.password); await CreateItems(Settings.email, Settings.password); await CreateProductImages(Settings.email, Settings.password); var result = from f in productList join s in imageList on f.productNo equals s.productNo into g select new { f.productNo, f.prodCategory, f.prodSubCategory, f.prodPrice, f.prodDescription, f.prodSize, f.prodColour, f.prodBrand, f.prodLocation, f.prodSold, f.prodSellerNo, g.First().prodImageString }; foreach (var e in result) { byte[] imageByte = Convert.FromBase64String(e.prodImageString); ImageSource imgSrc = ImageSource.FromStream(() => new MemoryStream(imageByte)); Image im = new Image(); im.HeightRequest = 500; im.WidthRequest = 400; im.Source = imgSrc; var prodItem = new tblProducts { prodCategory = e.prodCategory, prodSubCategory = e.prodSubCategory, prodPrice = e.prodPrice, prodDescription = e.prodDescription, prodSize = e.prodSize, prodColour = e.prodColour, prodBrand = e.prodBrand, prodLocation = e.prodLocation, prodSold = e.prodSold, prodSellerNo = e.prodSellerNo }; } } catch (Exception ex) { throw ex; } }
public void SaveProduct(tblProducts tblProducts) => _repository.SaveProduct(tblProducts);
public void SaveProduct(tblProducts tblProducts) { _context.tblProducts.Add(tblProducts); _context.SaveChangesAsync(); }