036 Creating Views for the Modeling Lookup Resource of PhbkDivision - chempkovsky/CS82ANGULAR GitHub Wiki

Definition

read the following article as reminder

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

Steps required to accomplish the task

Views for LpdDivision

Run ModelViews Wizard for LpdDivision
  • To Add a View to the project
    • Run Visual Studio and Open “PhonebookSolution” solution
    • Right Click “PhBk” of the LpPhBkViews-project and select “ModelView Wizard” menu item to open the Wizard dialog
      • Note: LpPhBkViews-project is used instead of PhBkViews-project
Click to show the picture

project structure

First page of the Wizard for 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
Click to show the picture

project structure

Second page of the Wizard for LpdDivision

repeat the steps described in the article

Third page of the Wizard for LpdDivision
  • On the third page of the Wizard we select Entity for the View. Choose PhBkEntity.csproj and LpdDivision-class and click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for LpdDivision

repeat the steps described in the article

Fifth page of the Wizard for LpdDivision
  • On the fifth page of the Wizard we define subset of properties, we turn on Jenerate JsonProperty Attribute-CheckBox, we Title and Plural Title for the given view.
  • click Next-button
Click to show the picture

project structure

Sixth page of the Wizard for LpdDivision

repeat the steps described in the article

Seventh page of the Wizard for LpdDivision

repeat the steps described in the article

Eighth page of the Wizard for LpdDivision

repeat the steps described in the article

Ninth page of the Wizard for LpdDivision

repeat the steps described in the article

  • The LpdDivisionView.cs and LpdDivisionViewPage.cs will be created in the PhBk-folder of the LpPhBkViews.csproj-project.
  • Open each file and put all generated code inside #if (!NOTMODELING) ... #endif-operator
Click to show the code
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace PhBkViews.PhBk {
    public class LpdDivisionView {
        // [JsonProperty(PropertyName = "divisionNameId")]
        [JsonPropertyName("divisionNameId")]
        [Required]
        [Display(Description="Row id",Name="Id of the Row",Prompt="Enter Row Id",ShortName="Row Id")]
        public System.Int32  DivisionNameId { get; set; }

        // [JsonProperty(PropertyName = "divisionName")]
        [JsonPropertyName("divisionName")]
        [Required]
        [Display(Description="Name of the Enterprise Division",Name="Name of the Division",Prompt="Enter Division Name",ShortName="Division Name")]
        [StringLength(20,MinimumLength=3,ErrorMessage="Invalid")]
        public System.String  DivisionName { get; set; } = null!;

    }
}
  • and
Click to show the code
namespace PhBkViews.PhBk {
    public class LpdDivisionViewPage {
        public int page { get; set; }
        public int pagesize { get; set; }
        public int pagecount { get; set; }
        public int total { get; set; }
        public List<LpdDivisionView> items { get; set; } = null!;
    }
}

Views for LprDivision01

Run ModelViews Wizard for LprDivision01
First page of the Wizard for LprDivision01
Second page of the Wizard for LprDivision01

repeat the steps described in the article

Third page of the Wizard for LprDivision01
  • On the third page of the Wizard we select Entity for the View. Choose PhBkEntity.csproj and LprDivision01-class and click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for LprDivision01

repeat the steps described in the article

Fifth page of the Wizard for LprDivision01
  • On the fifth page of the Wizard we define subset of properties, we turn on Jenerate JsonProperty Attribute-CheckBox, we Title and Plural Title for the given view.
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs01 node in the tree
    • In the right panel select master View (in our case it is PhbkDivisionView)
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs01 node in the tree
    • In the right panel replace DivisionPhbkDivisionView with D in the Foreign Key Prefix-control
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs01 node in the tree
    • expand Properties-sub node
    • uncheck All properties
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / DivisionNameDict: DivisionRefs01 node in the tree
    • In the right panel select master View (in our case it is LpdDivisionView)
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / DivisionNameDict: DivisionRefs01 node in the tree
    • In the right panel replace DivisionNameDictLpdDivisionView with ND in the Foreign Key Prefix-control
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / DivisionNameDict: DivisionRefs01 node in the tree
    • expand Properties-sub node
    • uncheck All properties
Click to show the picture

project structure

  • click Next-button

Sixth page of the Wizard for LprDivision01

repeat the steps described in the article

Seventh page of the Wizard for LprDivision01

repeat the steps described in the article

Eighth page of the Wizard for LprDivision01

repeat the steps described in the article

Ninth page of the Wizard for LprDivision01

repeat the steps described in the article

The LprDivision01View.cs and LprDivision01ViewPage.cs will be created in the PhBk-folder of the LpPhBkViews.csproj-project

Click to show the code
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;


namespace LpPhBkViews.PhBk {
    public class LprDivision01View {
        // [JsonProperty(PropertyName = "divisionId")]
        [JsonPropertyName("divisionId")]
        [Required]
        [Display(Description="Row id",Name="Id of the Division",Prompt="Enter Division Id",ShortName="Division Id")]
        public System.Int32  DivisionId { get; set; }

        // [JsonProperty(PropertyName = "divisionNameIdRef")]
        [JsonPropertyName("divisionNameIdRef")]
        [Required]
        [Display(Description="Row id",Name="Id of the Division",Prompt="Enter Division Id",ShortName="Division Id")]
        public System.Int32  DivisionNameIdRef { get; set; }

    }
}
  • and
Click to show the code
namespace LpPhBkViews.PhBk {
    public class LprDivision01ViewPage {
        public int page { get; set; }
        public int pagesize { get; set; }
        public int pagecount { get; set; }
        public int total { get; set; }
        public List<LprDivision01View> items { get; set; } = null!;
    }

}

Views for LprDivision02

Run ModelViews Wizard for LprDivision02
First page of the Wizard for LprDivision02
Second page of the Wizard for LprDivision02

repeat the steps described in the article

Third page of the Wizard for LprDivision02
  • On the third page of the Wizard we select Entity for the View. Choose PhBkEntity.csproj and LprDivision02-class and click Next-button
Click to show the picture

project structure

Fourth page of the Wizard for LprDivision02

repeat the steps described in the article

Fifth page of the Wizard for LprDivision02
  • On the fifth page of the Wizard we define subset of properties, we turn on Jenerate JsonProperty Attribute-CheckBox, we Title and Plural Title for the given view.
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs02 node in the tree
    • In the right panel select master View (in our case it is PhbkDivisionView)
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs02 node in the tree
    • In the right panel replace DivisionPhbkDivisionView with D in the Foreign Key Prefix-control
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Division: DivisionRefs02 node in the tree
    • expand Properties-sub node
    • uncheck All properties
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / Enterprise: DivisionRefs02 node in the tree
    • In the right panel select master View (in our case it is PhbkEnterpriseView)
    • Make the setting as they shown below
Click to show the picture

project structure

  • On the fifth page of the Wizard click Foreign Keys / DivisionNameDict: DivisionRefs02 node in the tree
    • In the right panel select master View (in our case it is LpdDivisionView)
    • Make the setting as they shown below
Click to show the picture

project structure

  • click Next-button

Sixth page of the Wizard for LprDivision02

repeat the steps described in the article

Seventh page of the Wizard for LprDivision02

repeat the steps described in the article

Eighth page of the Wizard for LprDivision02

repeat the steps described in the article

Ninth page of the Wizard for LprDivision02

repeat the steps described in the article

The LprDivision02View.cs and LprDivision02ViewPage.cs will be created in the PhBk-folder of the LpPhBkViews.csproj-project

Reset Directory Build props file again

At the end, 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
⚠️ **GitHub.com Fallback** ⚠️