private async Task CreateNewProduct(UIMouseEventArgs e) { var results = await _gatewayService.products.CreateProduct(product); if (results != null) { await OnProductCreated.InvokeAsync(null); } }
public ServiceResponse Create(ProductDto product) { try { var validator = new CreateProductValidator(); var validationResult = validator.Validate(product); if (!validationResult.IsValid) { return(new ServiceResponse <bool> { Success = false, Message = "Product not created!", Errors = GetValidationErrors(validationResult) }); } var data = new Product { ProductCode = product.ProductCode, Price = product.Price, Stock = product.Stock }; _uow.ProductRepository.Add(data); _uow.Save(); OnProductCreated?.Invoke(product.ProductCode); return(new ServiceResponse { Success = true, Message = "Product created successfully." }); } catch (Exception ex) { return(ex.ToResponse()); } }