public async Task <IActionResult> AddProduct(Guid id, [FromBody] AddProductRequest?request) { var command = Carts.AddingProduct.AddProduct.Create( id, ProductItem.Create( request?.ProductItem?.ProductId, request?.ProductItem?.Quantity ) ); await commandBus.Send(command); return(Ok()); }
public async Task <IActionResult> AddProduct(Guid id, [FromBody] AddProductRequest request) { Guard.Against.Null(request, nameof(request)); Guard.Against.Null(request.ProductItem, nameof(request)); var command = Commands.AddProduct.Create( id, ProductItem.Create( request.ProductItem.ProductId, request.ProductItem.Quantity ) ); await commandBus.Send(command); return(Ok()); }
public async Task <IActionResult> AddProduct(Guid id, [FromBody] AddProductRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } var command = Carts.AddingProduct.AddProduct.Create( id, ProductItem.Create( request.ProductItem?.ProductId, request.ProductItem?.Quantity ) ); await commandBus.Send(command); return(Ok()); }
/// <summary> /// Create new product variety /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { Product selectedProduct = (Product)cmbProducts.SelectedItem; ProductSize selectedSize = (ProductSize)cmbSizes.SelectedItem; try { short productID = (selectedProduct).Id; byte size = (selectedSize).Id; decimal price = Convert.ToDecimal(txtPrice.Text); ProductItem newItem = new ProductItem(size, price, productID); newItem.Create(); showMsg($"Successfully added product, {selectedProduct.Name} of size, {selectedSize}", true); } catch (SqlException se) { if (se.Message.Contains("duplicate key")) { showMsg($"Product {selectedProduct.Name} already has a size of {selectedSize}. Please try again", false); } } }