public void CatalogManager_WebStoreShowCatalog_InternalException() { var mgr = CreateWebStoreCatalogManager(); var response = mgr.ShowCatalog(99); WebStore.WebStoreCatalog catalog = response.Catalog; Assert.IsFalse(response.Success); }
public void CatalogManager_WebStoreShowCatalog() { var mgr = CreateWebStoreCatalogManager(); var response = mgr.ShowCatalog(1); WebStore.WebStoreCatalog catalog = response.Catalog; Assert.IsTrue(response.Success); Assert.AreEqual(1, catalog.Id); Assert.AreEqual(2, catalog.Products.Length); Assert.AreEqual("My Product", catalog.Products[0].Name); Assert.AreEqual("My Second Product", catalog.Products[1].Name); Assert.AreEqual("My Webstore", catalog.Name); }
WebStore.WebStoreCatalogResponse WebStore.IWebStoreCatalogManager.ShowCatalog(int catalogId) { try { // Get the webstore catalog WebStore.WebStoreCatalog result = new WebStore.WebStoreCatalog(); ICatalogAccessor catalogAccessor = AccessorFactory.CreateAccessor <ICatalogAccessor>(); DTO.WebStoreCatalog accCatalog = catalogAccessor.Find(catalogId); // Get the webstore catalog products if (accCatalog != null) { DTOMapper.Map(accCatalog, result); DTO.Product[] catalogProducts = catalogAccessor.FindAllProductsForCatalog(catalogId); List <WebStore.ProductSummary> productList = new List <WebStore.ProductSummary>(); foreach (var catalogProduct in catalogProducts) { WebStore.ProductSummary product = new WebStore.ProductSummary(); DTOMapper.Map(catalogProduct, product); productList.Add(product); } result.Products = productList.ToArray(); return(new WebStore.WebStoreCatalogResponse() { Success = true, Catalog = result }); } return(new WebStore.WebStoreCatalogResponse() { Success = false, Message = "Catalog not found" }); } catch (Exception ex) { Logger.Error(ex); return(new WebStore.WebStoreCatalogResponse() { Success = false, Message = "There was a problem accessing the catalog" }); } }