Codebase analysis · CoreStory V3

Contoso Customers and Orders

A Windows sample application (C#, UWP) for managing customers, orders and products, backed by an ASP.NET Core service and a SQL database. A sample published by Microsoft; this page is not affiliated with or endorsed by Microsoft.

Maintained by
Microsoft
License
MIT
Commit analyzed
247226c93728c5a2a0601575ed732206ca6949e7
Rules extracted
2026-11-15
Extracted by CoreStory V3
311
accepted rules, each with a cited source quote
12
capabilities
145
features
01 · Rules

Business rules, traced to source lines.

These 11 rules are a sample of the 311 CoreStory V3 extracted from Contoso Customers and Orders. Each one links to the exact lines on GitHub at commit 247226c. The statement is CoreStory V3’s wording; the code excerpt is the source it cites.

calculation
ContosoModels/Order.cs

The Order subtotal is computed as the sum over each LineItem of the product's ListPrice multiplied by the line item quantity.

public decimal Subtotal => LineItems.Sum(lineItem => lineItem.Product.ListPrice * lineItem.Quantity);
calculation
ContosoModels/Order.cs

The Order tax is computed as the subtotal multiplied by 0.095m.

  • 0.095 — tax rate multiplier applied to subtotal
public decimal Tax => Subtotal * .095m;
calculation
ContosoModels/Order.cs

The Order grand total is computed as the subtotal plus the tax.

public decimal GrandTotal => Subtotal + Tax;
calculation
ContosoRepository/Sql/SqlOrderRepository.cs

When upserting an Order for which no existing Order with the same Id is found, the new Order's InvoiceNumber is set to the maximum existing InvoiceNumber plus 1 before the order is added.

  • 1 — increment added to the maximum existing invoice number
if (null == existing) { order.InvoiceNumber = _db.Orders.Max(_order => _order.InvoiceNumber) + 1; _db.Orders.Add(order);
cascade delete condition
ContosoRepository/Sql/SqlCustomerRepository.cs

Deleting a customer looks up the customer by Id; if a customer is found, all orders whose CustomerId equals that Id are removed, the customer is removed, and changes are saved.

var customer = await _db.Customers.FirstOrDefaultAsync(_customer => _customer.Id == id); if (null != customer) { var orders = await _db.Orders.Where(order => order.CustomerId == id).ToListAsync(); _db.Orders.RemoveRange(orders); _db.Customers.Remove(customer); await _db.SaveChangesAsync(); }
enumeration
ContosoModels/Order.cs

Order statuses are restricted to the values Open, Filled, and Cancelled.

  • Open — allowed OrderStatus value
  • Filled — allowed OrderStatus value
  • Cancelled — allowed OrderStatus value
public enum OrderStatus { Open, Filled, Cancelled }
enumeration
ContosoModels/Order.cs

Order terms are restricted to the values Net1, Net5, Net15, and Net30.

  • Net1 — allowed Term value
  • Net5 — allowed Term value
  • Net15 — allowed Term value
  • Net30 — allowed Term value
public enum Term { Net1, Net5, Net15, Net30 }
enumeration
ContosoModels/Order.cs

Payment statuses are restricted to the values Unpaid and Paid.

  • Unpaid — allowed PaymentStatus value
  • Paid — allowed PaymentStatus value
public enum PaymentStatus { Unpaid, Paid }
derivation
ContosoModels/Order.cs

When an Order is created for a given customer, it sets Customer to that customer, CustomerName to the concatenation of the customer's FirstName and LastName separated by a space, CustomerId to the customer's Id, and Address to the customer's Address.

public Order(Customer customer) : this() { Customer = customer; CustomerName = $"{customer.FirstName} {customer.LastName}"; CustomerId = customer.Id; Address = customer.Address; }
search matching calculation
ContosoRepository/Sql/SqlCustomerRepository.cs

A customer search splits the supplied search value on a single space character, converts it to an array of parameters, and matches a customer when any parameter is a prefix of the customer's FirstName, LastName, Email, Phone, or Address; results are ordered descending by the count of parameters that prefix-match any of those five fields.

string[] parameters = value.Split(' '); return await _db.Customers .Where(customer => parameters.Any(parameter => customer.FirstName.StartsWith(parameter) || customer.LastName.StartsWith(parameter) || customer.Email.StartsWith(parameter) || customer.Phone.StartsWith(parameter) || customer.Address.StartsWith(parameter))) .OrderByDescending(customer => parameters.Count(parameter => customer.FirstName.StartsWith(parameter) || customer.LastName.StartsWith(parameter) || customer.Email.StartsWith(parameter) || customer.Phone.StartsWith(parameter) || customer.Address.StartsWith(parameter))) .AsNoTracking() .ToListAsync();
validation
ContosoService/Controllers/OrderController.cs

A GET search request returns BadRequest when the supplied search value is null, empty, or consists only of white-space characters; otherwise the search proceeds.

if (String.IsNullOrWhiteSpace(value)) { return BadRequest(); }
02 · Capabilities

What the application does

12 capabilities identified, grouping 117 of the 117 distinct features extracted. These are descriptions, not the cited rules above.

Customer Management

Creating, editing, listing, searching, and deleting customer records and their contact and address details across the UI, API, and storage layers.

  • Address Management: Lets users view and expand customer address information in the interface.
  • Customer Address Handling: Storage of customer addresses alongside customer identity information.
  • Customer Change Persistence: Saves modified customer data and supports reverting unsaved changes.
  • Customer Contact Display: Provides a customer entity with contact details that can be rendered as a human-readable string.
  • Customer Creation: Create a new customer through a dedicated action.
  • Customer Data Management: Persistent storage and retrieval of customer records.
  • Customer Data Refresh: Reloads customer information from the backing data source.
  • Customer Detail Display: A page displays customer details to the user, with navigation into and out of the view.
  • Customer Details Display: Shows customer profile information including name, contact, company, and primary address.
  • Customer Editing: Lets a user begin, edit, and end changes to a customer's details such as name, address, and contact information.
  • Customer HTTP API: A REST-style controller exposing HTTP operations (GET, POST, DELETE, search) over customer records.
  • Customer Information Display: Capability to view and manage customer information on an order.
  • Customer List Display: Presents a customer list to the user within the application shell.
  • Customer List Loading Indicator: Exposes a loading state so the UI can indicate that customer data is being fetched.
  • Customer List Synchronization: Refreshes the customer list by fetching updated data through an asynchronous sync operation.
  • Customer Loading: Load customer data for display and selection within the order management view.
  • Customer Lookup: Load and surface customer details such as name and address for the current order.
  • Customer Record Deletion: Allows removing a customer record asynchronously through the repository.
  • Customer Record Management: Provides CRUD-style capabilities to retrieve, create-or-update, and delete customer records through a repository abstraction.
  • Customer Record Retrieval: Allows retrieval of a customer record by its identifier through an asynchronous repository call.
  • Customer Record Upsert: Allows creating or updating a customer record asynchronously through the repository.
  • Customer Search: Provides a search box to find customers when working with orders.
  • New Customer Creation: Enables creating a new customer and canceling that creation.

Order Management

Composing, persisting, retrieving, viewing, editing, and deleting orders including their line items, totals, and statuses.

  • Line Item Management: Add and edit order line items, including binding updates and change tracking for new line items.
  • New Order Creation: Create and initialize a fresh order view model, distinguishing new orders from existing loaded ones.
  • Order Browsing: Displays a list of orders in a data grid within a split view layout.
  • Order Change Reversion: Track whether the order view model has unsaved modifications and support reverting back to the loaded state.
  • Order Creation: Lets a user add a new order through the order entry interface.
  • Order Deletion: Remove an order from the list on user request.
  • Order Detail Display: Shows detailed information for the selected order in an info panel.
  • Order Details Viewing: Opens order details through a context menu, keyboard, or double-tap gesture on a grid row.
  • Order Edit and Delete: Provides actions to edit or delete a selected order from the list.
  • Order Editing: Provides command bar actions to edit an order from the page.
  • Order Line Management: Allows users to add, remove, and revert product line items on an order detail page.
  • Order List Display: Presents an order list to the user within the application shell.
  • Order List Viewing: Display and browse the list of orders, including loading orders for a selected customer and showing grand total information.
  • Order Management: Creation and storage of customer orders including invoice details, dates, line items, and monetary totals.
  • Order Persistence: Store, upsert, and delete order records through a repository abstraction.
  • Order Refresh: Reloads the current order detail data on demand.
  • Order Retrieval: Load and display an existing order with its customer, line items, totals and statuses in the order view model.
  • Order Save: Persists the edited order detail to its backing store via the save action.
  • Order Submission: Add an order via a dedicated action.
  • Order Suggestion Update: Present and update suggested orders to the user alongside the main order list.
  • Order Totals Display: Capability to view the calculated totals for an order.
  • Order Viewing: Lets a user open and inspect an existing order's details.

Application Navigation and Shell

Moving between pages and sections, launching the app window, and hosting content in a themed application shell with page titles.

  • Adaptive Page Layout: Renders the page with a responsive layout that adjusts via visual state triggers.
  • App Navigation: Allows users to navigate between pages and sections using a navigation view with back navigation and item invocation.
  • Application Window Launch: Launching and displaying the application's main window at startup.
  • Order List Navigation: Navigates users to the order list page and initializes its view model.
  • Page Navigation: Navigate to and away from the customer list page.
  • Page Navigation Lifecycle: Hooks into navigation enter/leave events to initialize and clean up the order detail page state.
  • Page Title Display: Applies a shared typographic style for rendering page titles in the application UI.
  • Responsive Layout: Arranges UI elements in a responsive layout that adapts to available space.
  • Responsive Window Layout: Defines named window size breakpoints and header metrics so the UI adapts its layout across small, medium, and large window states.
  • Settings Page: A settings page that displays the app's settings and provides license and privacy information actions.
  • Stack Panel Layout: Provides a user-interface layout container that arranges child elements in a stacked sequence.
  • Themed Application Chrome: Provides Windows Fluent-style theming for window captions and application accent/background colors through merged theme and control resource dictionaries.
  • Visual State Transitions: Switches between named visual states to adapt the UI presentation.
  • Window Display: Provides the top-level user-facing window container that hosts and displays the application's UI content.

Backend and Data Source Integration

Configuring and consuming REST and SQLite/SQL data sources, including HTTP request serialization and repository access.

  • Contoso REST API Access: Provides access to Contoso customers, orders, and products through a REST client authenticated with an access token.
  • Data Source Selection: Lets the user choose between REST and SQLite data sources, updating the app when the selection changes.
  • JSON Request Serialization: Ability to send and receive JSON payloads over HTTP requests and responses.
  • Order Retrieval and Upsert via REST: Provides asynchronous CRUD-style access to orders through a REST backend, including fetching a single order, fetching orders for a customer, and creating or updating orders.
  • Product Retrieval over REST: Fetches product data from a remote REST API using an HTTP client and bearer access token.
  • REST API Consumption: Client capability to issue HTTP GET, POST, and DELETE requests against a configured base URL.
  • REST API Integration: Enabling the app to communicate with a REST backend service.
  • REST Customer Repository: A REST-backed repository that lets callers retrieve, create/update, and delete customer records over HTTP with token-authenticated requests.
  • SQL Data Access: A SQL-backed repository exposing customer, order, and product data for applications to read and write.
  • SQLite Persistence: Enabling the app to store and retrieve data locally using SQLite.

Command, Menu, and Dialog Interactions

Command bars, context menus, and modal dialogs with their button actions, including unsaved-changes prompting.

  • Command Bar Actions: Presents a command bar of actions users can invoke on the current view.
  • Content Dialog Button Actions: User-triggered handling of the dialog's primary, secondary, and close button clicks.
  • Content Dialog Display: A modal dialog presenting a title and content with configurable primary, secondary, and close buttons that users can act on.
  • Context Menu Actions: Provides a right-click context menu offering row-level actions to the user.
  • Edit Cancellation: Allows canceling one or more pending edits, including asynchronous cancellation.
  • Order Command Bar: Capability to access primary order actions via a command bar.
  • Page Command Bar Actions: Presents a main command bar with menu flyout actions available to the user.
  • Unsaved Changes Prompt: A dialog that prompts the user to save, discard, or cancel changes before proceeding.

Authentication and Session Management

Signing users in and out, acquiring and caching access tokens, and driving the authentication UI state and user profile presentation.

  • Access Token Acquisition: Retrieves an authentication token for the application via the MSAL public client, a capability callers depend on to authenticate API requests.
  • Account Listing: Enumerates the signed-in user accounts available to the client application.
  • Authentication View State Display: Drives the visible authentication UI states such as loading, welcome, error, and data display.
  • Cached Token Management: Configures token caching and allows removal of cached tokens to control persisted authentication state.
  • User Login: Authenticates a user and loads their profile information into the app.
  • User Logout: Signs the current user out and resets the authentication view state.
  • User Profile Photo Display: Displays the authenticated user's photo in the authentication view.

Product Catalog

Storing, retrieving, searching, and presenting product details and suggestions for use in orders.

  • Product API: Exposes product operations over a service endpoint backed by a product repository.
  • Product Catalog Management: Persistent storage and retrieval of product records.
  • Product Information Display: Exposes product details such as name, description, pricing, weight, color, and manufacturing time for presentation to users or consuming systems.
  • Product Retrieval: Asynchronous lookup of product data through the product repository abstraction.
  • Product Search: Capability to search for products to add to an order.
  • Product Suggestions: Provide and update product suggestions when selecting items for a new line item.

Help, Legal, and External Links

Access to license information, privacy policy, the code repository, and email actions from the app.

  • Code Repository Access: Provides a GitHub button for users to navigate to the project's code repository.
  • License Information Access: Allows the user to open or view license information from the page.
  • Order Email: Sends an email related to an order via an email action button.
  • Privacy Policy Access: Allows the user to open or view the privacy policy from the page.
  • Send Email: Provides an action to send an email from the order detail page.

Order and Payment Status

Tracking and updating order lifecycle statuses and payment terms, and displaying them to users.

  • Order Status Display: Capability to view the current status and progress of an order.
  • Order Status Tracking: Tracking the lifecycle state of an order through statuses such as open, filled, cancelled, paid, and unpaid.
  • Order Status Update: Set and observe the order and payment statuses along with their available value choices.
  • Payment Status Display: Capability to view payment status and terms for an order.
  • Payment Term Selection: Association of a payment term (Net5, Net15, Net30, or Net1) with an order to indicate its due schedule.

Search and Filtering

Collapsible search box input, query submission, suggestion selection, and result filtering across customers, orders, and products.

  • Collapsible Search Box: A collapsible search box that lets users expand and collapse a search input with animated icon states.
  • Order Search: Lets a user search for orders via a collapsible search box within the page.
  • Search Box Toggle Interaction: Pointer-driven expand/collapse interactions on the toggle button controlling the search box state.
  • Search Query Submission: Triggers a search action when the user types into or submits the search box.
  • Search Result Filtering: Filtering of search results with distinct non-filtered and filtered visual states and icon feedback.

Tabular Data Presentation

Sortable, column-configured data grids for presenting lists of records with sorting and row selection.

  • Data Binding Notification: A bindable base class that raises property change notifications so bound UI elements update when a property is set.
  • Data Grid Display: Displays tabular data in a sortable, column-configured grid with an associated context menu.
  • Data Grid Sorting: Allows users to sort tabular listings by column.
  • Progress Indication: Shows a progress bar to indicate ongoing activity status to the user.
  • View Model Change Notification: Raises property change notifications so bound UI elements react to view model updates.

Project and Build Configuration

Authoring the project file structure with target framework selection, references, and source-code linking.

  • Code Link Action: Provides an action to open or navigate to the application's source code.
  • Project File Structure Authoring: Provides the ability to author a project file as an organized container of items, properties, and build targets.
  • Project Reference Management: Enables declaring and consuming references to other projects and external packages so the build composes additional assemblies.
  • Target Framework Selection: Lets the user declare which .NET target framework(s) the project builds against.
03 · Size

What was analyzed

  • SQL · 1 file · 16,236 lines
  • C# · 47 files · 2,813 lines
  • XAML · 11 files · 1,714 lines
  • Markdown · 4 files · 343 lines
  • MSBuild script · 4 files · 162 lines
  • Visual Studio Solution · 1 file · 131 lines
  • XML · 2 files · 55 lines
  • JSON · 4 files · 50 lines
  • Text · 1 file · 24 lines

Whole repository: 153 files. cloc 2.06 counts 21,528 lines of code in 75 of them (24,813 lines with comments and blanks).

04 · Source

Where this came from

Extracted by CoreStory V3 (build 4470 with two small engine fixes) using DeepSeek-V4.1-Flash from the public repository at commit 247226c on 2026-11-15. Capability descriptions are from the same run.

Code excerpts are from the upstream repository and remain under its MIT license. CoreStory is not affiliated with or endorsed by Microsoft.

Want this for your own codebase?

Talk to us about mapping the business rules in your repositories.

Talk to an expert