041 Web Api services for Lookup resource of PhbkDivisionView - chempkovsky/CS82ANGULAR GitHub Wiki

Notes

  • We need to generate each Web Api service twice. The first time is for modeling. (The Wizard's repo for PhbkDbContext will be updated). The second time is for production. (The Wizard's repo for LpPhbkDbContext will be updated). We can not copy/paste from one repo to another. Entities declared for PhbkDbContext-repo differ from those which are defined for LpPhbkDbContext-repo. Some foreign keys for entities of LpPhbkDbContext-repo were removed.

Steps required to accomplish the task

Web Api Services for Modeling repo

Reset Directory Build props file

  • Before we start, open Directory.Build.props-file and modify it as follows:
<Project>
    <PropertyGroup>
        <DefineConstants>MODELING</DefineConstants>
    </PropertyGroup>
</Project>
  • save the Directory.Build.props-file
  • rebuild PhBkContext-project

Web Api Services for modeling LpdDivision

Run WebApi Wizard for modeling LpdDivision
  • To Generate Web Api service
    • Run Visual Studio and Open PhonebookSolution solution
    • Right Click Controllers of the LpPhBkControllers-project and select WebApiServices Wizard menu item to open the Wizard dialog
Click to show the picture

project structure

First page of the Wizard for modeling LpdDivision
  • On the first page of the dialog the destination folder is shown. The destination folder is the folder in which the generated file will be created. Click Next-button
Second page of the Wizard for modeling LpdDivision

On the second page of the Wizard we select DbContext that will be used to choose the entity for the View. Select PhBkContext.csproj and the PhBkContext class using the drop-down lists. Click Next-button.

Third page of the Wizard for modeling LpdDivision
  • On the third page of the Wizard
      1. select View
      1. choose the props to be used for sorting and filtering
      1. choose WebApi methods to generate
      1. if to generate localized typescript code-CheckBox using Angular i18n
  • Click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for modeling LpdDivision

  • On the Fourth page of the Wizard we choose DefaultWebApiService.Core.cs.t4 T4-template to generate the code. Click Next-button.

Fifth page of the Wizard for modeling LpdDivision

  • repeat the steps described in the article The LpdDivisionViewWebApiController.cs will be created in the Controllers-folder of the LpPhBkControllers.csproj-project

Web Api Services for modeling LprDivision01View

Third page of the Wizard for modeling LprDivision01View
  • On the third page of the Wizard
      1. select View
      1. choose the props to be used for sorting and filtering
      1. choose WebApi methods to generate
      1. if to generate localized typescript code-CheckBox using Angular i18n
  • Click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for modeling LprDivision01View

  • On the Fourth page of the Wizard we choose DefaultWebApiService.Core.cs.t4 T4-template to generate the code. Click Next-button.

Fifth page of the Wizard for modeling LprDivision01View

  • repeat the steps described in the article The LprDivision01ViewWebApiController.cs will be created in the Controllers-folder of the LpPhBkControllers.csproj-project

Web Api Services for modeling LprDivision02View

Third page of the Wizard for modeling LprDivision02View
  • On the third page of the Wizard
      1. select View
      1. choose the props to be used for sorting and filtering
      1. choose WebApi methods to generate
      1. if to generate localized typescript code-CheckBox using Angular i18n
  • Click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for modeling LprDivision02View

  • On the Fourth page of the Wizard we choose DefaultWebApiService.Core.cs.t4 T4-template to generate the code. Click Next-button.

Fifth page of the Wizard for modeling LprDivision02View

  • repeat the steps described in the article The LprDivision02ViewWebApiController.cs will be created in the Controllers-folder of the LpPhBkControllers.csproj-project

Reset Directory Build props file again

  • Open Directory.Build.props-file and modify it as follows:
<Project>
    <PropertyGroup>
        <DefineConstants>NOTMODELING</DefineConstants>
    </PropertyGroup>
</Project>
  • save the Directory.Build.props-file
  • rebuild PhBkContext-project

Web Api Services for production

Web Api Services for LpdDivision

Run WebApi Wizard for LpdDivision
First page of the Wizard for LpdDivision
Second page of the Wizard for LpdDivision

On the second page of the Wizard we select DbContext that will be used to choose the entity for the View. Select LpPhBkContext.csproj and the LpPhbkDbContext class using the drop-down lists. Click Next-button.

Other pages for LpdDivision
  • The View defined for the PhbkDbContext and the View defined for the LpPhBkContext are identical
    • As a result, other pages of the Wizard will be the same as for modeling LpdDivision.

Web Api Services for LprDivision01View

Web Api Services for LprDivision02View

⚠️ **GitHub.com Fallback** ⚠️