public bool update(int id, ProductUpdateVO data) { var product = new Product() { UpdatedAt = data.updatedAt, Name = data.name, Price = data.price, Quantity = data.quantity, ImagePath = data.imagePath, CatID = data.catId }; return(_productDAO.update(id, product)); }
private void BtnDone_Click(object sender, RoutedEventArgs e) { string image = ""; if (imageSelect != null) { image = PassImage(); } if (isUpdate == false) { var product = new ProductCreateVO(); product.name = tbName.Text; product.quantity = int.Parse(tbQuantity.Text); product.price = int.Parse(tbPrice.Text); product.catId = (cbbCategorySelect.SelectedItem as Category).ID; product.imagePath = imageSelect != null ? image : ""; var validateString = product.validate(); if (validateString.Length > 0) { MessageBox.Show(validateString); return; } productBus.insert(product); FunctionHelper.CallPaginationFilter(ActionPagination.Load); } else { var product = new ProductUpdateVO(); product.name = tbName.Text; product.quantity = int.Parse(tbQuantity.Text); product.price = int.Parse(tbPrice.Text); product.catId = (cbbCategorySelect.SelectedItem as Category).ID; product.imagePath = imageSelect != null ? image : productSelected.ImagePath; product.SKU = productSelected.SKU; var validateString = product.validate(); if (validateString.Length > 0) { MessageBox.Show(validateString); return; } productBus.update(productSelected.ID, product); FunctionHelper.CallPaginationFilter(ActionPagination.Load); } DisableForm(); isUpdate = false; }