public void Update() { // Arrange IProductWorker ProductWorker = new ProductWorker(); string name = GenerateRandomName("Disco duro"); ProductDto productDto = new ProductDto() { Description = "Otro producto", Name = name, UnitPrice = 150000 }; // ACT ProductWorker.Create(productDto); productDto.UnitPrice = 170000; var productById = ProductWorker.Search(name); productDto.ID = productById.ID; ProductWorker.Update(productDto); // Assert var product = ProductWorker.Search(name); Assert.AreEqual(product.UnitPrice, productDto.UnitPrice, "No se actualizo correctamente"); }
protected void gridView_RowDeleting(object sender, GridViewDeleteEventArgs e) { GridViewRow row = gridView.Rows[e.RowIndex]; long ProductId = long.Parse(row.Cells[2].Text.ToString()); ProductWorker pw = new ProductWorker(); pw.DeleteProduct(ProductId); List <Product> products = (List <Product>)Session["Products"]; products.Remove(products.Find(o => o.Id == long.Parse(row.Cells[2].Text.ToString()))); Session.Add("Products", products); PopulateProducts(products); }
protected void btnResetDatabase_Click(object sender, EventArgs e) { ProductWorker pw = new ProductWorker(); int result = pw.ResetDatabase(); if (result > -1) { MessageBox(result.ToString() + " Products were reset"); } else { MessageBox("There was an error resetting the database."); } }
private WarehouseWorker warehouseWorker; // TR: Depo //EN : Take product out of the warehouse / TR : Ürününün depodan düşülmesi public bool TakeProduct(Product product, double amount) { bool result = false; productWorker = new ProductWorker(); result = productWorker.UpdateAmount(product, amount); if (result) { warehouseWorker = new WarehouseWorker(); result = warehouseWorker.PrepareOutputReceipt(product, amount); } return(result); }
public void Search() { // Arrange IProductWorker ProductWorker = new ProductWorker(); string name = GenerateRandomName("Soporte de portátil"); ProductDto ProductDto = new ProductDto() { Description = "Producto viejo", Name = name, UnitPrice = 40000 }; // ACT ProductWorker.Create(ProductDto); var product = ProductWorker.Search(name); // Assert Assert.AreEqual(product.Name, ProductDto.Name, "No se encontró el producto"); }
public void Create() { // Arrange IProductWorker ProductWorker = new ProductWorker(); string name = GenerateRandomName("Mac Pro"); ProductDto productDto = new ProductDto() { Description = "Un producto", Name = name, UnitPrice = 5000000 }; // ACT ProductWorker.Create(productDto); // Assert var product = ProductWorker.Search(name); Assert.AreEqual(product.Name, productDto.Name, "No se inserto correctamente"); }
public void ChangeState() { // Arrange IProductWorker ProductWorker = new ProductWorker(); string name = GenerateRandomName("Teclado gamer"); ProductDto productDto = new ProductDto() { Description = "Nuevo producto", Name = name, UnitPrice = 230000 }; // ACT ProductWorker.Create(productDto); var productById = ProductWorker.Search(name); productDto.ID = productById.ID; ProductWorker.ChangeState(productDto.ID, false); // Assert var product = ProductWorker.Search(name); Assert.AreEqual(product.Enable, productDto.Enable, "No se cambio el estado correctamente"); }
public IActionResult Get(string id) { var worker = new ProductWorker(_settings.ElasticSearchClientSettings); return(worker.Get(id)); }
protected void btnQuickAddProduct_Click(object sender, EventArgs e) { if (txtCompanyName.Text != string.Empty && txtCategory.Text != string.Empty && txtFlavor.Text != string.Empty) { lblError.Visible = true; Product p = new Product(); p.Category = txtCategory.Text.Trim(); p.CompanyName = txtCompanyName.Text.Trim(); p.Flavor = txtFlavor.Text.Trim(); if (chkCF.Checked) { p.CF = true; } else { p.CF = false; } if (chkSF.Checked) { p.SF = true; } else { p.SF = false; } if (chkCT.Checked) { p.CRT = true; } else { p.CRT = false; } if (chkFC.Checked) { p.FAC = true; } else { p.FAC = false; } p.LastUpdated = DateTime.Now; p.Type1 = txtType1.Text; p.Type2 = txtType2.Text; p.User = ((Users)Session["User"]).UserName; ProductWorker w = new ProductWorker(); bool result = w.AddProduct(p); if (result) { MessageBox("Product Added!"); } else { MessageBox("Product Add Error!"); } Session.Remove("Products"); ClearQuickAddProduct(); } else { MessageBox("Category, Company or Flavor cannot be empty"); //lblError.Text = "Category, Company or Flavor cannot be empty"; //lblError.Visible = true; } }
protected void btnSearch_Click(object sender, EventArgs e) { if (((txtCompanySearch.Text != string.Empty || txtCategorySearch.Text != string.Empty) && (rdbCategory.Checked || rdbCompany.Checked)) || (txtCompanySearch.Text != string.Empty && txtCategorySearch.Text != string.Empty && (rdbBoth.Checked || rdbAny.Checked))) { lblsearchResults.Visible = true; lblSearchBy.Visible = true; string categorysearch = txtCategorySearch.Text; string companysearch = txtCompanySearch.Text; lblError.Visible = false; bool isCategory = false; bool isSingleFilter = false; if (categorysearch != string.Empty && companysearch == string.Empty) { isCategory = true; } if (!rdbAny.Checked && !rdbBoth.Checked) { isSingleFilter = true; if (isCategory) { lblSearchBy.Text = "Search by Category: " + categorysearch; } else { lblSearchBy.Text = "Search by Company: " + companysearch; } } else { isSingleFilter = false; if (rdbAny.Checked) { lblSearchBy.Text = "Search by Company: " + companysearch + " or Search by Category: " + categorysearch; } else { lblSearchBy.Text = "Search by Company: " + companysearch + " and Search by Category: " + categorysearch; } } ProductWorker w = new ProductWorker(); if (isSingleFilter && isCategory) { _Products = w.SearchProduct(categorysearch, isCategory); } else if (isSingleFilter && !isCategory) { _Products = w.SearchProduct(companysearch, isCategory); } else if (!isSingleFilter) { _Products = w.SearchProduct(categorysearch, companysearch, rdbBoth.Checked); } Session.Add("Products", _Products); lblsearchResults.Text = "Search Results: " + this._Products.Count.ToString() + " products found"; gridView.PageIndex = 0; PopulateProducts(this._Products); ClearSearchBoxes(); Session.Remove("Expression"); Session.Remove("IsAscending"); } else { if (txtCompanySearch.Text == string.Empty && txtCategorySearch.Text == string.Empty) { MessageBox("Enter a Search String"); } else if ((txtCompanySearch.Text != string.Empty && txtCategorySearch.Text != string.Empty && (!rdbBoth.Checked || !rdbAny.Checked))) { MessageBox("Check either Any or Both radio button"); } else if (txtCategorySearch.Text != string.Empty && txtCompanySearch.Text == string.Empty && !rdbCategory.Checked) { MessageBox("Check Category radio button"); } else if (txtCategorySearch.Text == string.Empty && txtCompanySearch.Text != string.Empty && !rdbCompany.Checked) { MessageBox("Check Company radio button"); } } }
public ProductController(DataFactory dataFactory) { _productWorker = (ProductWorker)dataFactory.GetDataFactory <Product>(); }