Now let us walk through the generated code for the GetList. Let start with the generated output api model.
public class GetCustomersForLookupOutputAPIModel : IFlexOutputAPIModel
{
public string Id { get; set; }
public string Name { get; set; }
public DateTime DateOfBirth { get; set; }
}
So if you see here in web controller we have the GetCustomersForLookup is the GetList.
public partial class CustomerController : FlexControllerBridge
{
/// <summary>
///
/// </summary>
/// <returns></returns>
[HttpGet()]
[Route("GetCustomersForLookup")]
[ProducesResponseType(typeof(IEnumerable<GetCustomersForLookupOutputAPIModel>), 200)]
public IActionResult GetCustomersForLookup([FromQuery]GetCustomersForLookupParams parameters)
{
FlexHostContextInfoBridge hostContextInfo = new FlexHostContextInfoBridge();
hostContextInfo.Populate<IFlexHostHttpContextAccesorBridge>(_appHttpContextAccessor);
parameters.SetHostContextInfo(hostContextInfo);
return Ok(ProcessCustomerService.GetCustomersForLookup(parameters));
}
}
Since the parameter get customer by lookup uses the same ContextInfo, we cannot expose those parameter to the API. So its implemented as protected.
That is the ideal way that works like that. So to avoid exposing the parameter to the API. This particular parameter is made protected.
Lets look at the Services layer.
public partial class ProcessCustomerService : IProcessCustomerService
{
/// <summary>
/// YourRemarksForMethod
/// </summary>
/// <param name="params"></param>
/// <returns></returns>
public IEnumerable<GetCustomersForLookupOutputAPIModel> GetCustomersForLookup(GetCustomersForLookupParams @params)
{
return _flexHost.GetFlexiQuery<GetCustomersForLookup>().AssignParameters(@params).Fetch();
}
}
GetList implements the FlexiQueryEnumerableBridge.
The same way we have the Fetch and we have the ProjectTo so do the mapping for the customer model to this output API model.
So once the query is executed the control flows back to the services and the controller gives the result back to the consumer of the API.