LymeTools: Anatomy of a Feature

Below is the screen snippet of the git output when scaffolding a new generic feature. This view provides an easy way to visualize what files were added or changed with Scaffold Feature tool.

Git Repo Change Log from Visual Studio 2022

Tip: If you have a clean git repository (all edit files checked in or stashed) prior to scaffolding a new feature, it will be easy to see this for yourself and also make it easy to undo any changes in case you selected any incorrect configuration options when scaffolding a feature.

Explanation of Changed Files

As you can see, quite a few files are added and changed when scaffolding a new feature. Here's an explanation:

API Files

Folder File Git Action Description
/LymeTemplateApi.Models NewFeature.cs Add The Entity Framework class file that maps back to the database.
/LymeTemplateApi/Controllers NewFeatureController.cs Add The ASP.NET WebApi Controller that provides REST endpoints for CRUD and Search operations. For more info see the Controller Endpoint Breakdown.
/LymeTemplateApi.Data DataContext.cs Modify The Entity Framework DataContext class that ties the above mentioned database model to the SQL Server Database
/LymeTemplateApi.Models/Api NewFeatureSearchOptions.cs Add The C# class that is used as an input parameter for the API's Search endpoint.
/LymeTemplateApi.Models/ -- MyGenerationSpec.cs Modify The TypeLite generation specification file that indicates that a TypeScript class file will be automatically generated in the API project when the Models project is built. This enables a strongly typed new-feature.ts file, making our application's intellisense aware of our new feature.

Angular App Files

Folder File Git Action Description
/ app.routes.ts Modify The root application module route file. When scaffolding a new feature, a line gets added to lazy-load the new feature at the route: http://myapp/app/new-features
/new-features new-features.module.ts Add The base module containing declarations to all the generated UI components.
/new-features new-features.routes.ts Add The Angular route file that tells the application which components to load based on the URL in the address bar of the browser.
/new-features new-features.component.* Add The root Angular component that loads when navigating to the root route in your browser. In this example: http://myapp/new-features. This component displays the search options, paginated/sortable search results, and an Excel export button be default. An 'Add a New Feature' button is also available to add a new record and each search result has and Edit, Delete, and View action button scaffolded by default
/new-features/new-feature new-feature.component.* Add An HTML display of a single instance of a NewFeature database record
/new-features/new-feature-form new-feature-form.component.* Add The Angular component that contains the form HTML elements used to add or edit an instance of a NewFeature record.
/new-features/new-feature-list new-feature-list.component.* Add An Angular component that is responsible for listing a collection of NewFeature objects that typically come from the API Search endpoint.
/new-features/new-feature-modal new-feature-modal.component.* Add An Angular Material dialog modal that displays a single instance of a a NewFeature record from the database.
/new-features/new-feature-search-options new-feature-search-options.component.* Add The Angular component that contains the Search Form UI that is displayed in the feature's root route. The data model for this component maps back to the NewFeatureSearchOptions.cs class in the API.

Controller Endpoints on a Generic Feature

A generic feature comes with the following endpoints by default.

Route HTTP Verb Example Description
<default> GET http://myapp/api/NewFeature Gets all records from the database
GET http://myapp/api/NewFeature/123 Gets a single record from the database
POST http://myapp/api/NewFeature/123 Saves a single record from the database. Note that this endpoint will both Create (Insert) and Update (Modify) a record depending on the value of the incoming entity's Id key field value. Submit the NewFeature object as the body of the HTTP request.
DELETE http://myapp/api/NewFeature/123 Deletes a record from the database.
Search POST http://myapp/api/NewFeature/Search?pageSize=10&pageIndex=0 Search the NewFeature database table. Submit the NewFeatureSearchOptions object to indicate what fields are to be searched. The pageSize and pageIndex query parameters handle pagination
ExportToExcel POST http://myapp/api/NewFeature/ExportToExcel Generates a Microsoft Excel .xlsx file. Submit the NewFeatureSearchOptions object to indicate what fields are to be included.

Angular App Routes for a Generic Feature

URL Description
http://myapp/new-features The root route to your newly scaffolded feature.
http://myapp/new-features/add A form to add a new instance of a NewFeature record in the database. This route is navigated to automatically when pressing the "Add New Feature" button on the main view described above.
http://myapp/new-features/edit/123 A form to edit an existing NewFeature record in the database. This route is navigated to automatically when clicking the "Edit" option on a search result.