Admin.AdminProductResponse Admin.IAdminCatalogManager.ShowProduct(int catalogId, int productId) { try { //authenticate the seller if (UtilityFactory.CreateUtility <ISecurityUtility>().SellerAuthenticated()) { var product = AccessorFactory.CreateAccessor <ICatalogAccessor>() .FindProduct(productId); if (product != null) { if (product.CatalogId == catalogId) { Admin.Product result = new Admin.Product(); DTOMapper.Map(product, result); return(new Admin.AdminProductResponse() { Success = true, Product = result }); } } return(new Admin.AdminProductResponse() { Success = false, Message = "Product not found" }); } return(new Admin.AdminProductResponse() { Success = false, Message = "Seller not authenticated" }); } catch (Exception ex) { Logger.Error(ex); return(new Admin.AdminProductResponse() { Success = false, Message = "There was a problem accessing the product" }); } }
Admin.AdminProductResponse Admin.IAdminCatalogManager.SaveProduct(int catalogId, Admin.Product product) { try { // authenticate the user as a seller if (UtilityFactory.CreateUtility <ISecurityUtility>().SellerAuthenticated()) { // map to the accessor DTO DTO.Product accProduct = new DTO.Product(); DTOMapper.Map(product, accProduct); accProduct = AccessorFactory.CreateAccessor <ICatalogAccessor>().SaveProduct(catalogId, accProduct); if (accProduct != null) { Admin.Product result = new Admin.Product(); DTOMapper.Map(accProduct, result); return(new Admin.AdminProductResponse() { Success = true, Product = result }); } return(new Admin.AdminProductResponse() { Success = false, Message = "Product not saved" }); } return(new Admin.AdminProductResponse() { Success = false, Message = "Seller not authenticated" }); } catch (Exception ex) { Logger.Error(ex); return(new Admin.AdminProductResponse() { Success = false, Message = "There was a problem saving the product" }); } }