private void EditProduct_Click(object sender, RoutedEventArgs e) { ViewProduct nextPage = new ViewProduct(); NavigationService navService = NavigationService.GetNavigationService(this); navService.Navigate(nextPage); }
private void products_Click(object sender, EventArgs e) { if (!tabControl.TabPages.ContainsKey("p1")) { p1 = new ViewProduct(this.idioma); tabControl.Visible = true; p1.MdiParent = this; p1.WindowState = FormWindowState.Normal; p1.FormBorderStyle = FormBorderStyle.None; p1.TopLevel = false; p1.Dock = DockStyle.Fill; p1.Show(); TabPage tp = new TabPage(products.Text); tp.Tag = p1; tp.Name = "p1"; tp.Parent = tabControl; tabControl.SelectedTab = tp; p1.Tag = tp; } else { int n = tabControl.TabPages.IndexOfKey("p1"); tabControl.SelectTab(n); } }
public IActionResult Validate(ViewProduct newProduct) { var all = _context.products.ToList(); ViewBag.Products = all; if (ModelState.IsValid) { Products product = new Products { name = newProduct.name, price = newProduct.price, description = newProduct.description, instock_quantity = newProduct.instock_quantity, weight = newProduct.weight, image_url = newProduct.image_url, x_dimension = newProduct.x_dimension, y_dimension = newProduct.y_dimension, z_dimension = newProduct.z_dimension, created_at = DateTime.Now, updated_at = DateTime.Now, }; _context.products.Add(product); _context.SaveChanges(); return(RedirectToAction("Inventory")); } return(View("Inventory", newProduct)); }
public List <ViewProduct> UpdateProduct(ViewProduct product) { List <ViewProduct> response = new(); var updateModel = _mapper.Map <DAL.Entities.Product>(product); updateModel.PriceTl = updateModel.Price * updateModel.ExchangeTl; var currentModel = _productRepository.GetById(updateModel.Id); if (currentModel != null) { _productRepository.UpdateMatchEntity(currentModel, updateModel, true); //Insert Redis var cacheKey = string.Format(ProductDetail, updateModel.Id); var model = _mapper.Map <ViewProduct>(updateModel); _redisCacheManager.Set(cacheKey, model); //------------------------------- response = GetProductList();; } else { throw new NotImplementedException(); } return(response); }
private void MappingProductToViewProduct(Product product) { var viewProduct = new ViewProduct() { Sku = product.Sku, IsMarketable = product.IsMarketable, Name = product.Name }; viewProduct.Inventory = new ViewInventory() { Quantity = product.Inventory.Quantity }; viewProduct.Inventory.WareHouses = new List <ViewWareHouse>(); foreach (var waireHouse in product.Inventory.WareHouses) { viewProduct.Inventory.WareHouses.Add(new ViewWareHouse() { Locality = waireHouse.Locality, Quantity = waireHouse.Quantity, Type = waireHouse.Type } ); } Products.Add(viewProduct); }
public IActionResult ValidateEdit(int id, ViewProduct edit) { var all = _context.products.ToList(); ViewBag.Products = all; if (ModelState.IsValid) { Products current_product = _context.products.SingleOrDefault(p => p.product_id == id); { current_product.name = edit.name; current_product.price = edit.price; current_product.description = edit.description; current_product.instock_quantity = edit.instock_quantity; current_product.weight = edit.weight; current_product.image_url = edit.image_url; current_product.x_dimension = edit.x_dimension; current_product.y_dimension = edit.y_dimension; current_product.z_dimension = edit.z_dimension; current_product.updated_at = DateTime.Now; _context.SaveChanges(); }; return(RedirectToAction("Inventory")); } return(View("Inventory", edit)); }
public List <ViewProduct> InsertProduct(ViewProduct product) { var data = _mapper.Map <Product>(product); _productRepository.Insert(data, true); //Insert Redis var cacheKey = string.Format(ProductDetail, data.Id); var model = _mapper.Map <ViewProduct>(data); model.SeriNo = product.SeriNo; //SeriNo Decrypt olaraka atanır. _redisCacheManager.Set(cacheKey, model); //------------------------------- //Add RabbitMQ ExchangeQueue queueData = new ExchangeQueue() { ProductID = data.Id, Name = data.Name, ExchangeName = ((ExchangeParseType)data.ExchangeType).ToString(), ExchangeType = data.ExchangeType, Price = data.Price, ConnectionID = product.ConnectionId, TotalCount = data.TotalCount, SeriNo = product.SeriNo }; _rabbitMQService.Post("product", queueData); //------------------------ var responseData = GetProductList(); return(responseData); }
public IActionResult AddProduct(ViewProduct info) { if (info != null) { Storage storage = storegeRepository.Storages.Where(p => p.Id == info.SelectedStorage).FirstOrDefault(); Currency currency = currencyRepository.Currencies.Where(p => p.Id == info.SelectedCurrency).FirstOrDefault(); Random rnd = new Random(); Product prod = productRepository.AddProduct(new Product { Name = info.Name, Price = info.Price, CategoryId = info.SelectedCategory, Count = info.Count, CurrencyId = info.SelectedCurrency, BasicCurrPrice = info.Price * currency.ExchangeRate, Barcode = rnd.Next(10000000, 99999999), ProductStorages = new List <ProductStorage> { new ProductStorage { StorageId = storage.Id } } }); } return(RedirectToAction("Index", "Home")); }
public async Task <IActionResult> AddAsync(ViewProduct vp) { vp.NewProduct.ProductDate = DateTime.Today; _context.Products.Add(vp.NewProduct); await _context.SaveChangesAsync(); return(RedirectToAction("AddReceipt", vp.NewProduct)); }
// GET: Products public IActionResult Index2() { ViewProduct vp = new ViewProduct(); vp.Brands = _context.Brand.ToList(); vp.ProductTypes = _context.ProductType.ToList(); vp.Products = _context.Product.Where(p => p.ParentId == null).ToList(); return(View(vp)); }
public IEnumerable <ViewProduct> GetProducts(string otherOptions) { using (var db = new MvvmSampleEntities()) { var results = from p in (from p in db.Products select p).ToList() select ViewProduct.FromProduct(p); return(results); } }
public IActionResult AddReceipt(Product NewItem) { NewAddProducts.Add(NewItem); ViewProduct vp = new ViewProduct { Products = NewAddProducts }; return(View(vp)); }
public IEnumerable <ViewProduct> GetProducts() { using (var db = new Entities2()) { var results = from p in (from p in db.Products select p).ToList() select ViewProduct.FromProduct(p); return(results); } }
public IActionResult Index() { //get the item whose store is null or empty var products = _context.Products.Where(p => p.Store == " " || p.Store == null); ViewProduct vp = new ViewProduct() { Products = products.ToList() }; return(View(vp)); }
public ResponseModel <ViewProduct> GetView(long id) { ResponseModel <ViewProduct> res = new ResponseModel <ViewProduct>(); ViewProduct vp = new ViewProduct(); vp.Product = _productManager.GetAll().result.FirstOrDefault(t => t.ProductID == id); vp.Photo = null; vp.Category = categoryManager.GetAll().result.FirstOrDefault(t => t.CategoryID == vp.Product.CategoryID); res.result = vp; return(res); }
private void BtnViweProduct_Click(object sender, EventArgs e) { Product foo = new Product(); ViewProduct view = (ViewProduct)foo; view.Title = "Sony"; view.Count = 40; List <string> list = new List <string>(); }
private ProductDetailsResponse CreateProductResponse(DomainCore.Models.Product product) { ViewProduct result = _mapper.Map <ViewProduct>(product); if (product.Image != null) { result.Photo = _mapper.Map <ImageFile>(product.Image); } return(new ProductDetailsResponse { Product = result }); }
public AppController(DbEntities context) { this.Context = context; Regcontroller = new RegistrationController(context); // Create anonymous user for adding items to cart before logging in User.Anonymous = true; this.OrderController = new OrderController(context, this.User); this.ViewOrder = new ViewOrder(context, OrderController); MainMenu MainMenu = new MainMenu(this); this.ViewUserPanel = new ViewUserPanel(this); ViewProduct = new ViewProduct(context, MainMenu); }
public List <ViewProduct> GetAll() { //fetch db.animal data, and pull all rows table into RAM var products = db.Products.ToList(); //convert this data into view data var viewProducts = new List <ViewProduct>(); foreach (var li in products) { var viewProduct = new ViewProduct(li); viewProducts.Add(viewProduct); } //return return(viewProducts); }
public Models.SaveResult SaveProduct(ViewProduct product) { using (var db = new MvvmSampleEntities()) { var target = new Product(); db.Products.Add(target); target.SetProperties(product); db.SaveChanges(); } // end using(db) return(new Models.SaveResult { success = true }); } // end function
// GET: Product public ActionResult Index(int id) { ViewProduct data = new ViewProduct { Product = db.Products.Find(id), }; data.categories = db.Categories.Where(c => c.DepartmentId == data.Product.Category.DepartmentId).ToList(); data.related = db.Products.Where(p => p.CategoryId == data.Product.CategoryId).OrderByDescending(p => p.Id).Take(10).ToList(); if (data.Product == null) { return(HttpNotFound()); } return(View(data)); }
public IEnumerable <ViewProduct> InsertProduct([FromBody] ViewProduct model) { if (model != null) { if (model.ID > 0) { return(_productService.UpdateProduct(model)); } else { return(_productService.InsertProduct(model)); } } return(new List <ViewProduct>()); }
public async Task <ActionResult> PushProduct([FromBody] ExchangeQueue productQueue) { try { System.Threading.Thread.Sleep(2000); //:) Hahahaha ViewProduct product = _mapper.Map <ViewProduct>(productQueue); product = _productService.UpdateProduct(product).FirstOrDefault(p => p.ID == product.ID); await _dispatcher.PushProduct(product); } catch (System.Exception ex) { int i = 0; } return(Ok()); }
public ActionResult NewItem(ViewProduct product) { ViewBag.Title = "New Product Item"; using (var db = new MvvmSampleEntities()) { var target = new Product(); db.Products.Add(target); target.SetProperties(product); db.SaveChanges(); } // end using(db) // このサンプルでは、製品の登録が完了すると、Productsページにリダイレクトします。 //「登録しました」ページを表示する場合は、そのことを表示するビューの表示を用意してViewを返すように変更します。 return new RedirectResult("~/Products"); } // end function
protected void Page_Load(object sender, EventArgs e) { if (!string.IsNullOrEmpty(Request.QueryString["pi"])) { var oProduct = new Product(); var dv = oProduct.ProductSelectOne(Request.QueryString["pi"]).DefaultView; ViewProduct view = new ViewProduct(); view.CreateView(dv[0]["ProductID"].ToString(), dv[0]["CategoryID"].ToString(), dv[0]["ImageName"].ToString(), dv[0]["ProductNameEn"].ToString(), !string.IsNullOrEmpty(dv[0]["Price"].ToString()) ? (string.Format("{0:##,###.##}", dv[0]["Price"]).Replace('.', '*').Replace(',', '.').Replace('*', ',')) : ""); } if (!IsPostBack) { string strTitle, strDescription, strMetaTitle, strMetaDescription; if (!string.IsNullOrEmpty(Request.QueryString["pi"])) { var oProduct = new Product(); var dv = oProduct.ProductSelectOne(Request.QueryString["pi"]).DefaultView; if (dv != null && dv.Count <= 0) { return; } var row = dv[0]; strTitle = Server.HtmlDecode(row["ProductCategoryNameEn"].ToString()); strDescription = Server.HtmlDecode(row["DescriptionEn"].ToString()); strMetaTitle = Server.HtmlDecode(row["MetaTittleEn"].ToString()); strMetaDescription = Server.HtmlDecode(row["MetaDescriptionEn"].ToString()); //hdnSanPham.Value = progressTitle(dv[0]["ProductCategoryName"].ToString()) + "-pci-" + dv[0]["ProductCategoryID"].ToString() + ".aspx"; } else { strTitle = strMetaTitle = "Products"; strDescription = ""; strMetaDescription = ""; } Page.Title = !string.IsNullOrEmpty(strMetaTitle) ? strMetaTitle : strTitle; var meta = new HtmlMeta() { Name = "description", Content = !string.IsNullOrEmpty(strMetaDescription) ? strMetaDescription : strDescription }; Header.Controls.Add(meta); //lblTitle.Text = strTitle; } }
public IActionResult Detail(int id) { var product = productRepository.Get(id); var model = new ViewProduct() { ProductId = product.ProductId, ProductName = product.ProductName, BrandName = product.Brand, ImagePath = product.PathImage, Price = product.Price, catelogyid = product.CategoryId, Description = product.Description, size = product.Size }; return(View(model)); }
public ActionResult Edit(ViewProduct vProduct) { Product product = new Product(); product.ProductId = vProduct.Id; product.Price = vProduct.Price; product.CatagoryId = vProduct.CatagoryId; if (productRepo.Update(product) == 1) { return(RedirectToAction("Index", "Product")); } else { return(View("Error")); } }
public QuickViewPage quickViewProduct(string strProductName) { foreach (var Product in collProducts) { if (Product.GetAttribute("title") == strProductName) { Actions action = new Actions(PropertiesCollection.driver); action.MoveToElement(Product).Perform(); break; } } Thread.Sleep(6000); WebDriverWait wait = new WebDriverWait(PropertiesCollection.driver, TimeSpan.FromSeconds(16)); var element = wait.Until(ExpectedConditions.ElementIsVisible(By.LinkText("Quick view"))); ViewProduct.Click(); return(new QuickViewPage()); }
public static Product CreateProduct() { var cityId = context.Cities.Where(x => x.Name == "Bacau").ToList()[0].Id; var categoryId = context.Categories.Where(x => x.Name == "Other").ToList()[0].Id; var viewProduct = new ViewProduct() { CityId = cityId, Description = "nothing interesting here just a description for this", UserName = "******", CategoryId = categoryId, Title = "One plus 2", Price = 1500, TradesAccepted = true }; var product = Mapper.Map <Product>(viewProduct); return(product); }
public IActionResult Edit(ViewProduct EditingProduct) { Product product = pc.Products.Include(p => p.Groups).SingleOrDefault((s) => s.Id == EditingProduct.Id); if (product != null) { byte[] byteArray = null; if (EditingProduct.Image != null) { using (Image img = Image.FromStream(EditingProduct.Image.OpenReadStream())) { if (img.Width > 320 || img.Height > 480) { byteArray = img.Resize(320, 480).ToByteArray(); } else { byteArray = img.ToByteArray(); } } product.Image = byteArray; } product.Name = EditingProduct.Name; product.Description = EditingProduct.Description; product.Country = EditingProduct.Country; product.Measure = EditingProduct.Measure; product.Price = EditingProduct.Price; product.Groups.DriedFruits = EditingProduct.Groups.DriedFruits; product.Groups.EasternMed = EditingProduct.Groups.EasternMed; product.Groups.Grocery = EditingProduct.Groups.Grocery; product.Groups.Italian = EditingProduct.Groups.Italian; product.Groups.Nuts = EditingProduct.Groups.Nuts; product.Groups.Oils = EditingProduct.Groups.Oils; product.Groups.Sauces = EditingProduct.Groups.Sauces; product.Groups.Spice = EditingProduct.Groups.Spice; product.Groups.Sweets = EditingProduct.Groups.Sweets; TryUpdateModelAsync <Product>(product); pc.SaveChanges(); } return(RedirectToAction("listofproducts", "Home")); }