/// <summary> /// This will return Product Children. /// </summary> /// <param name="parms"></param> /// <returns></returns> private async Task <List <ICommonWithId> > indexProductChild_DataListAsync(ControllerIndexParams parms) { //Get the product parms.ProductId.IsNullOrWhiteSpaceThrowException(); Product product = await ProductBiz.FindAsync(parms.ProductId); //parent product cannot be null. It is some kind of programming error if it is. product.IsNullThrowException(string.Format("Product not found. Id ='{0}'", parms.ProductId)); //update the number of visits if (!UserId.IsNullOrWhiteSpace()) { product.NoOfVisits.AddOne(UserId, UserName); await ProductBiz.UpdateAndSaveAsync(product); } //get all its child products and display them List <ProductChild> children; //see if the product is a shop if (product.OwnerId.IsNullOrWhiteSpace()) { //this is not a shop. children = productChildren(product); } else { //this is a shop children = shopChildren(product); } if (children.IsNullOrEmpty()) { return(null); } List <ICommonWithId> childrenAsIcommonLst = children.Cast <ICommonWithId>().ToList(); return(childrenAsIcommonLst); }