The business layer sits between the Entity Framework data context and the MVC controllers, exposing a set of static manager classes that encapsulate all LINQ queries against theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/aws-samples/legacy-cycle-store-mvc-app/llms.txt
Use this file to discover all available pages before exploring further.
CYCLE_STORE database. Rather than having controllers reference CYCLE_STOREEntities directly, every data-access call is routed through CategoryManager or ProductManager. This keeps query logic in one place and gives controllers a clean, method-level API — a common and pragmatic pattern in legacy ASP.NET MVC applications built before the repository and unit-of-work patterns became standard practice.
Common
Common is a tiny infrastructure class whose sole job is to construct a CYCLE_STOREEntities instance on demand.
Common.DataEntities to obtain a context, performs its query, and then lets the context fall out of scope.
Common.DataEntities creates a brand-new CYCLE_STOREEntities instance on every property access — there is no shared, long-lived context. This means two calls to Common.DataEntities within the same request yield two separate DbContext objects. As a result, there is no unit-of-work scope: entities fetched in one call are not tracked in another, and change-tracking across multiple manager method calls is not supported. For a read-heavy catalogue application this is acceptable, but it would be a problem if any write operations needed to span multiple queries atomically.CategoryManager
CategoryManager provides three static methods for retrieving category and subcategory data. All methods are in the AdventureWorks.Business namespace.
GetMainCategories
Returns every row inProductCategory as a materialised list.
.ToList() executes the SQL query immediately and closes the DbContext before returning. Callers receive a plain List<ProductCategory> with no live EF tracking.
GetCategoryByName
Finds a singleProductCategory by its exact Name value. Returns null if no match is found.
Name column. Pass the name exactly as stored in the database (e.g., "Bikes", not "bikes").
GetProductSubcategoryByName
Finds a singleProductSubcategory by exact name match. Returns null if no match is found.
ProductManager
ProductManager provides query methods for individual products and attribute-list helpers used to populate filter UIs. It operates on the same Common.DataEntities pattern as CategoryManager.
CategoryManager is declared in the AdventureWorks.Business namespace, while ProductManager is declared in the EpicAdventureWorks namespace — despite both classes residing in the same Business/ directory and using identical AdventureWorks.Business types. This namespace mismatch is a likely artifact of an incomplete rename or refactoring pass. Any code that references ProductManager must include a using EpicAdventureWorks; directive or use the fully-qualified name.GetProductByName
Returns the firstProduct whose Name exactly matches the given string, or null.
GetProductByCategory
Returns anIQueryable<Product> filtered to products belonging to the given subcategory. Because it returns IQueryable, the query is not executed until the caller iterates the result — callers can append additional .Where or .OrderBy clauses before materialising.
GetProductByProductId (two overloads)
The first overload usesCommon.DataEntities to obtain a context automatically:
Entities entities parameter, allowing the caller to supply an already-open context — useful when the caller needs the returned Product to remain tracked within an existing unit of work:
GetProductColor
Returns a deduplicated, alphabetically sorted list of non-null color values for all products in a given subcategory.GetProductWeight
Returns a deduplicated, ascending-sorted list of non-null weight values for all products in a given subcategory.GetProductSize
Returns a deduplicated, alphabetically sorted list of non-null size values for all products in a given subcategory.GetProductDesc
Fetches the description text for a givenProductDescriptionID from the ProductDescription table.
ProductDescription is not part of the three entities exposed on CYCLE_STOREEntities DbSets documented in the Data Model page — it is accessed through the EDMX-generated context which may expose additional sets beyond Products, ProductCategories, and ProductSubcategories.
Usage Example
The following example shows how a controller action would use the business layer to load navigation categories and then retrieve products for a selected subcategory:Common.DataEntities opens a new connection and DbContext. For a listing page that calls GetMainCategories, GetProductByCategory, GetProductColor, GetProductSize, and GetProductWeight, that is five separate DbContext instances and five database round-trips.