public WishDTO GetSingleWish(string stringId) { Guid wishId = Helper.SafeGuidParse(stringId); if (wishId == new Guid()) { Helper.MyPrint("Error: Invalid Wish id.", "r"); return(null); } else { List <Wish> allWishes = this.db.GetAllWish(); List <Product> allProd = this.db.GetAllProduct(); List <WishList> allWishLists = this.db.GetAllWishList(); List <ProductDTO> allProducts = new List <ProductDTO>(); allProd.ForEach(delegate(Product product) { allProducts.Add(ModelToDTOMapper.ProductMapper(product)); }); WishDTO wishDTO = new WishDTO(); Wish wish = this.db.GetSingleWish(Helper.SafeGuidParse(stringId)); if (wish != null) { return(this.GetFullWishWithItems(wish, allWishes, allProducts, allWishLists)); } } return(null); }
public List <WishDTO> GetAllWish() { List <Wish> wishes = this.db.GetAllWish(); List <Product> allProd = this.db.GetAllProduct(); List <WishList> allWishLists = this.db.GetAllWishList(); List <ProductDTO> allProducts = new List <ProductDTO>(); allProd.ForEach(delegate(Product product) { allProducts.Add(ModelToDTOMapper.ProductMapper(product)); }); List <WishDTO> wishDTOs = new List <WishDTO>(); foreach (Wish wish in wishes) { if (Helper.SafeGuidParse(wish.Id) == new Guid()) { Helper.MyPrint("Error: Invalid ID", "r"); } else { wishDTOs.Add(this.GetFullWishWithItems(wish, wishes, allProducts, allWishLists)); } } return(wishDTOs); }
public ProductDTO GetSingleProduct(string productId) { Guid id = Helper.SafeGuidParse(productId); if (id == new Guid()) { Helper.MyPrint("Invalid Product id", "r"); return(null); } else { return(ModelToDTOMapper.ProductMapper(this.db.GetSingleProduct(id))); } }
public List <ProductDTO> GetAllProduct() { // TODO: use linq List <Product> products = db.GetAllProduct(); List <ProductDTO> productDTOs = new List <ProductDTO>(); foreach (Product prod in products) { if (Helper.SafeGuidParse(prod.Id) == new Guid()) { Helper.MyPrint("Error: Invalid Id", "r"); } else { productDTOs.Add(ModelToDTOMapper.ProductMapper(prod)); } } return(productDTOs); }