APIs/Data Models (18%) Flashcards
True or False. Most of the time, mappers do not apply business logic?
True
Which requests may contain a query string and a body ?
POST, PUT and PATCH
From a payload, which kind of object is constructed and passed to the controller?
An API Model object
Name the 2 attributes that are used to determine which URL an endpoint will respond to?
RoutePrefix
Route
Which method is declared in the BaseApiController class and is responsible for the whole controller flow?
The ExecuteAsync method
What is the ExecuteAsync method?
It is a simple async wrapper around the synchronous Execute method
What is the responsibility of the Execute method from the BaseApiController class?
The Execute method is responsible for the whole API call flow.
It interacts with the mapper and the service to apply the business logic
Name the 4 steps done by the Execute method of the BaseApiController class
Map the API parameter to Service parameter
Call the service with the Service parameter
Map the Service Result back to an API result
Send back the API Result in the response
Which are the 3 common strategies adopted when developing custom API endpoints?
Simple service + controller (simple method)
Simple service + ExecuteAsync (hybrid method)
Service + Handler Chain (advanced method)
The ExecuteAsync method takes 5 generic types as parameters. Name them, in the correct order.
Mapper API Parameter Service Parameter Service Result API Result
Which Object Relational Model (ORM) B2B Commerce uses?
B2B Commerce uses Entity Framework Code First version 6
Where is the the ODataControllers.tt T4 template located?
In the Insite.Admin library
Is it possible for developers to extend the existing T4 template?
No. I t is recommended to implement a custom T4 template independently. Developers cannot extend the existing T4 template.
Describe 2 ways entities can be archived?
Setting the DateTime deactivate property to today’s date.
Setting the Boolean archive property to false.
How is it possible for a developers to retrieve archived entities?
Using the Admin API developers can retrieve archived entities by appending the archivedFilter=1 OData query
Which syntax is the Admin API using?
The Admin API uses OData syntax
Example:
Admin API return a single object syntax:
/api/v1/admin/products(f88d5c07-eb72-42eb-ab36-a5d201168a49)
Storefront API return a single object syntax:
/api/v1/products/f88d5c07-eb72-42eb-ab36-a5d201168a49
Which are here are two ways to retrieve child collections on a RESTful JSON result?
Use the expand parameter for the query string
Example: /api/v1/websites(d24h5c07-eb72-42eb-ab36-a5d201168jh5)?$expand=countries
Use the name of the child entity after the slash
Example: /api/v1/websites(d24h5c07-eb72-42eb-ab36-a5d201168jh5)/countries
True or False
All of the entities within B2B Commerce will contain a Patch endpoint for the Admin API to update them?
True
Where are the OData Entities models located?
The models are located in the Insite.Data.Entities library
What is the root namespace for entity-related components in the B2B Commerce framework?
Insite.Data
How to create an entity class?
- First create a POCO (Plain Old CLR Object) that extends from Insite.Data.Entities.EntityBase
- Then add properties with add virtual properties
From which library a new mapping class for a newly created entity class should extend?
It should extend from Insite.Data.Providers.EntityFramework.EntityMappings.EntityBaseTypeConfiguration
How to add an entity class?
- create a POCO (Plain Old CLR Object) that extends from Insite.Data.Entities.EntityBase
- add virtual properties to the class
From what a mapping class must extend a custom entity class to be bootstrapped to the context correctly?
From Insite.Data.Providers.EntityFramework.EntityMappings.EntityBaseTypeConfiguration
What are the 2 properties and values that must be set to properly for a SQL script to run automatically?
Setting the Build Action property of the file to Embedded Resource
Setting the Copy to Output Directory property to Do not copy
Which Optimizely optimization can be used to get a collection without tracking?
A) WithNoTracking
B) AsNoTracking
C) GetTableAsNoTracking
C) GetTableAsNoTracking
To get a collection without tracking, invoke the GetTableAsNoTracking method on the Repository.
Which connection string will have only read/write/execute privileges on all schemas and will no longer be the database owner and will not be allowed to execute SQL scripts or any DDL?
InSite.Commerce
Which connection string will have database owner rights and be able to do anything on any schema - this connection will be used to execute base scripts?
InSite.Commerce.Admin
Which connection string will have DDL rights to the Extensions schema only?
InSite.Commerce.Extensions
Which nuget package is required in your Extensions project to create a custom entity for your custom table?
EntityFramework v6.1.3
Signing into B2B involves two requests. What are they?
one to authenticate with Identity Server and a second to create an B2B session.