Skip to content

Instantly share code, notes, and snippets.

@avegaraju
Last active December 23, 2018 21:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save avegaraju/1e90438e3ae2c7aa8905977a751d74aa to your computer and use it in GitHub Desktop.
module UpdateProductDimensions
open Domain
open System
let find (productId:int, products: seq<Product>):Option<Product> =
products
|> Seq.tryPick<Product, Product>(fun x-> if x.ProductId = productId then Some(x) else None)
let update (productOption: Option<Product>, height, length, weight, width)=
match productOption with
| Some product -> Ok(product.updateDimensions (height, length, weight, width))
| None _ -> Error(new Exception("Product does not exist"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment