public async Task <IActionResult> Edit(int id, [Bind("ProductId,Name,Category,Color,Price,AvailableQuantity")] MyProducts products) { if (id != products.ProductId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(products); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ProductsExists(products.ProductId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(products)); }
public void RefreshList() { if (string.IsNullOrEmpty(this.Filter)) { var myListProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, IsAvailable = p.IsAvailable, Price = p.Price, ProductId = p.ProductId, PublishOn = p.PublishOn, Remarks = p.Remarks, }); this.Products = new ObservableCollection <ProductItemViewModel>(myListProductItemViewModel.OrderBy(p => p.Description)); } else { var myListProductItemViewModel = this.MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, IsAvailable = p.IsAvailable, Price = p.Price, ProductId = p.ProductId, PublishOn = p.PublishOn, Remarks = p.Remarks, }).Where(p => p.Description.ToLower().Contains(this.Filter.ToLower())).ToList(); this.Products = new ObservableCollection <ProductItemViewModel>(myListProductItemViewModel.OrderBy(p => p.Description)); } }
public void RefreshList() { var myListProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, IsAvailable = p.IsAvailable, Price = p.Price, ProductId = p.ProductId, PublishOn = p.PublishOn, Remarks = p.Remarks, }); /*para funciones ne lista*/ //var myList = new List<ProductItemViewModel>(); //foreach (var item in list) //{ // myList.Add(new ProductItemViewModel { // }); //} /**/ this.Products = new ObservableCollection <ProductItemViewModel>( myListProductItemViewModel.OrderBy(p => p.Description)); }
public void RefreshList() { var MylistProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, Price = p.Price, ProductId = p.ProductId, IsAvailable = p.IsAvailable, PublishOn = p.PublishOn, Remarks = p.Remarks, }); ////Se comenta este código porque no es muy practico hacerlo ya que puede ser tardado //var Mylist = new List<ProductItemViewModel>(); //foreach (var item in list) //{ // Mylist.Add(new ProductItemViewModel // { // }); //} //no se puede mandar una lista de productos, se tiene que mandar una lista de productItemView Model //hay dos maneras de hacerlo, una con un foreach que se encontrará comentado ya que en este caso es demasiado lento y //afecta en el performance y la otra manera es con una expresion lambda asignando cada uno de los atributos a la lista de //ProductItemViewModel this.Products = new ObservableCollection <ProductItemViewModel>(MylistProductItemViewModel.OrderBy(p => p.Description)); }
protected override void Seed(WebApiProject.Context.ProductContext context) { // This method will be called after migrating to the latest version. // You can use the DbSet<T>.AddOrUpdate() helper extension method // to avoid creating duplicate seed data. var Products = MyProducts.GetProductList(); context.Set <Product>().AddRange(Products); context.SaveChanges(); }
static void Main(string[] args) { // combine enum values to represent a mix of products MyProducts productMix = MyProducts.Apples | MyProducts.Bananas; // print out the product mix Console.WriteLine("Products: {0}", productMix); // wait for input before exiting Console.WriteLine("Press enter to finish"); Console.ReadLine(); }
private async void LoadProducts() { this.IsRefreshing = true; var connection = await this.apiService.CheckConnection(); if (!connection.IsSuccess) { this.IsRefreshing = false; await Application.Current.MainPage.DisplayAlert(Languages.Error, connection.Message, Languages.Accept); return; } var response = await this.apiService.GetList <Product>( "https://salesapijonalexjm.azurewebsites.net", "/api", "/Products", Settings.TokenType, Settings.AccessToken); this.IsRefreshing = false; if (!response.IsSuccess)// si funciono sigue pasando { await Application.Current.MainPage.DisplayAlert( Languages.Error, response.Message, Languages.Accept); return; } this.MyProducts = (List <Product>)response.Result; this.RefreshList(); var myListProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, IsAvailable = p.IsAvailable, Price = p.Price, ProductId = p.ProductId, PublishOn = p.PublishOn, Remarks = p.Remarks, }); this.Products = new ObservableCollection <ProductItemViewModel>(myListProductItemViewModel.OrderBy(p => p.Description)); this.IsRefreshing = false; }
public ActionResult Delete(int?id) { if (id == null) { return(NotFound()); } MyProducts pro = _context.allproducts.Find(id); if (pro == null) { return(NotFound()); } return(View(pro)); }
public void RefreshList() { var mylistProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { Description = p.Description, ImageArray = p.ImageArray, ImagePath = p.ImagePath, IsAvailable = p.IsAvailable, Price = p.Price, ProductId = p.ProductId, PublishOn = p.PublishOn, Remarks = p.Remarks, }); this.Products = new ObservableCollection <ProductItemViewModel>(mylistProductItemViewModel.OrderBy(p => p.Description)); }
public void fillDataDictionary() { myp = new MyProducts(); myp.produ(); var result = (from r in myp.GetAllProduct() select r).ToList(); productDic = new Dictionary <int, string>(); foreach (var r in result) { //fill dic productDic.Add(r.ProductCode, r.ProductName); } }
//private void AddItems() //{ // for (int i = 1; i < 5; i++) // { // MyProducts products = new MyProducts() // { // ImageSrc = "https://cdn.shopify.com/s/files/1/1432/5782/products/P4170481_grande.jpg?v=1587402041", // NameSrc = "Deneme" // }; // Items.Add(products); // } // //Items.Add(string.Format("List Item at {0}", i)); //} public ObservableCollection <MyProducts> GetNumberofItems(int numberofItem) { ObservableCollection <MyProducts> items = new ObservableCollection <MyProducts>(); foreach (var item in api.GetProduct()) { MyProducts products = new MyProducts() { ImageSrc = new Uri(item.Image), NameSrc = item.Name }; items.Add(products); if (items.Count == numberofItem) { break; } } return(items); }
public ActionResult Create(MyProducts pro) { if (ModelState.IsValid) { string wwwRootPath = _webHostEnvironment.WebRootPath; string fileName = Path.GetFileNameWithoutExtension(pro.ImageFile.FileName); string extension = Path.GetExtension(pro.ImageFile.FileName); pro.ImageName = fileName = fileName + DateTime.Now.ToString("yyMMddHHmmssff") + extension; string imagePath = Path.Combine(wwwRootPath + "/images/" + fileName); FileStream fileStream = new FileStream(imagePath, FileMode.Create); pro.ImageFile.CopyTo(fileStream); } _context.allproducts.Add(pro); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
public void RefreshList() { if (string.IsNullOrEmpty(this.Filter)) { var myListProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { description = p.description, imageArray = p.imageArray, imagePath = p.imagePath, available = p.available, price = p.price, productId = p.productId, publishOn = p.publishOn, remark = p.remark, category = p.category }); this.Products = new ObservableCollection <ProductItemViewModel>( myListProductItemViewModel.OrderBy(p => p.description)); } else { var myListProductItemViewModel = MyProducts.Select(p => new ProductItemViewModel { description = p.description, imageArray = p.imageArray, imagePath = p.imagePath, available = p.available, price = p.price, productId = p.productId, publishOn = p.publishOn, remark = p.remark, category = p.category }).Where(p => p.description.ToLower().Contains(this.Filter.ToLower())).ToList(); this.Products = new ObservableCollection <ProductItemViewModel>( myListProductItemViewModel.OrderBy(p => p.description)); } }
public void GenerateData() { MyCategory c1 = new MyCategory(1, "Shoes"); MyCategory c2 = new MyCategory(2, "Coats"); MyCategory c3 = new MyCategory(3, "Dresses"); MyCategories.Add(c1); MyCategories.Add(c2); MyCategories.Add(c3); MyVendor v1 = new MyVendor(1, "Clothing Company", "Los Angeles"); MyVendor v2 = new MyVendor(2, "Shoes Factory", "Warsaw"); MyVendor v3 = new MyVendor(3, "Great Shoes Inc.", "Pabianice"); MyVendor v4 = new MyVendor(4, "Bridal Dresses", "New York"); MyVendors.Add(v1); MyVendors.Add(v2); MyVendors.Add(v3); MyVendors.Add(v4); MyProduct p1 = new MyProduct(1, "Pretty Coat", "Brown", new decimal(199.99), c2, v1); MyProduct p2 = new MyProduct(2, "Coat", "Black", new decimal(199.99), c2, v1); MyProduct p3 = new MyProduct(3, "High Heels", "Brown", new decimal(259.99), c1, v2); MyProduct p4 = new MyProduct(4, "Sneakers", "White", new decimal(99.90), c1, v3); MyProduct p5 = new MyProduct(5, "High Boots", "Beige", new decimal(179.99), c1, v2); MyProduct p6 = new MyProduct(6, "Pretty White Dress", "White", new decimal(1999.99), c3, v4); MyProduct p7 = new MyProduct(7, "Bridal Dress", "White", new decimal(2500), c3, v4); MyProduct p8 = new MyProduct(8, "Pretty Dress", "Pink", new decimal(219.99), c3, v1); MyProducts.Add(p1); MyProducts.Add(p2); MyProducts.Add(p3); MyProducts.Add(p4); MyProducts.Add(p5); MyProducts.Add(p6); MyProducts.Add(p7); MyProducts.Add(p8); }
public ActionResult DeleteConfirmed(int id) { MyProducts pro = _context.allproducts.Find(id); try { var imagepath = Path.Combine(_webHostEnvironment.WebRootPath, "Images", pro.ImageName); if (System.IO.File.Exists(imagepath)) { System.IO.File.Delete(imagepath); } } catch { } _context.allproducts.Remove(pro); _context.SaveChanges(); return(RedirectToAction(nameof(Index))); }
private void LoadItems() { Device.BeginInvokeOnMainThread(async() => { try { var restClient = new RestClient(); var resp = await restClient.GetAsync <ServiceResponse <ProductsAndFacilities> >(AppConstants.BaseUrl + "Product"); if (resp.IsSuccess && resp.Data != null) { Products = new ObservableCollection <MyProducts>(); foreach (var item in resp.Data.Products) { var pd = new MyProducts { Id = item.Id, Name = item.Name, Description = item.Description, LocationX = item.LocationX, LocationY = item.LocationY, }; switch (pd.Name) { case "Water Bottle": pd.Source = "waterbottle.png"; break; case "Fridge": pd.Source = "fridge.png"; break; case "TV": pd.Source = "tv.png"; break; default: break; } Products.Add(pd); } Facilities = new ObservableCollection <MyProducts>(); foreach (var item in resp.Data.Facilities) { var pd = new MyProducts { Id = item.Id, Name = item.Name, Description = item.Description, LocationX = item.LocationX, LocationY = item.LocationY, }; switch (pd.Name) { case "Entry": pd.Source = "openeddoor.png"; break; case "Exit": pd.Source = "closeddoor.png"; break; default: break; } Facilities.Add(pd); } } } catch (Exception ex) { Console.WriteLine(ex); } }); }