/// <summary> /// Edits the product from the database /// </summary> public void Edit(string name, ProductCategory category, int unitSize, int unitPrice, Shelf shelf) { base.Update($@"UPDATE products SET name = '{name}', category_id = {category.Id}, unitSize = {unitSize}, unitPrice = {unitPrice}, shelf_id = {shelf.Id} WHERE id = {this.Id}"); // Write a status StatusHandler.Write($"Edited product {this.Name}", StatusHandler.Codes.SUCCESS); }
/// <summary> /// EditProduct method /// This methods makes it possible to edit a product through the shelf /// </summary> /// <param name="product">The product instance we want to edit</param> /// <param name="name">Edited name</param> /// <param name="category">Edited category</param> /// <param name="unitSize">Edited unitSize</param> /// <param name="unitPrice">Edited unitPrice</param> /// <param name="shelf">Edited shelf</param> public void EditProduct(Product product, string name, ProductCategory category, int unitSize, int unitPrice, Shelf shelf) { // First check if the product contains the the list of products if (this.products.Contains(product)) { product.Edit(name, category, unitSize, unitPrice, shelf); // Load shelves incase the shelf of the product has changed LoadShelves(); LoadProducts(); } else { StatusHandler.Write($"{product}, does not exist in the shelf' product list", StatusHandler.Codes.ERROR); } }