code_junkie

Models, Factories and Repositories

Nov 13th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Dim p As New Product
  2. If(p.Load(1))
  3. p.Name = "New Name"
  4. p.Save()
  5. End If
  6.  
  7. Dim arrProds = Product.GetProducts()
  8.  
  9. Dim prodSvc = ObjectFactory.GetInstance(Of IProductService)
  10. Dim prod = prodSvc.GetProduct(1) //Prod is an Instance of 'Product'
  11. prod.Name = "New Name"
  12. prodSvc.Save(prod)
  13.  
  14. Dim arrRelatedProds = prod.RelatedProducts
  15.  
  16. Class Product
  17. Function RelatedProducts() As IList(Of Product)
  18. // prodSvc is an instance of IProductService which is passed into the
  19. // Product class in the constructor (or via Dependency Injection)
  20. Return Me.prodSvc.GetRelatedProducts(Me.ProductID)
  21. End Function
  22. End Class
Add Comment
Please, Sign In to add comment