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" }); } }
Admin.AdminCatalogResponse Admin.IAdminCatalogManager.SaveCatalog(Admin.WebStoreCatalog catalog) { try { // authenticate the user as a seller if (UtilityFactory.CreateUtility <ISecurityUtility>().SellerAuthenticated()) { // map to the accessor DTO DTO.WebStoreCatalog accCatalog = new DTO.WebStoreCatalog(); DTOMapper.Map(catalog, accCatalog); accCatalog = AccessorFactory.CreateAccessor <ICatalogAccessor>().SaveCatalog(accCatalog); if (accCatalog != null) { Admin.WebStoreCatalog result = new Admin.WebStoreCatalog(); DTOMapper.Map(accCatalog, result); return(new Admin.AdminCatalogResponse() { Success = true, Catalog = result }); } return(new Admin.AdminCatalogResponse() { Success = false, Message = "Catalog not saved" }); } return(new Admin.AdminCatalogResponse() { Success = false, Message = "Seller not authenticated" }); } catch (Exception ex) { Logger.Error(ex); return(new Admin.AdminCatalogResponse() { Success = false, Message = "There was a problem saving the catalog" }); } }