010 First View (PhoneType). Wizard repository. - chempkovsky/CS82ANGULAR GitHub Wiki
- Run ModelViews Wizard
- First page of the Wizard
- Second page of the Wizard
- Third page of the Wizard
- Fourth page of the Wizard
- Fifth page of the Wizard
- Sixth page of the Wizard
- Seventh page of the Wizard
- Eighth page of the Wizard
- Ninth page of the Wizard
- View (or ModelView) is the structure that the WebApi service sends to and receives from the client. For each entity, the developer must create at least one view.
- View (or ModelView) is a Data Transfer Objects (DTO)
- For a given entity, the View (or ModelView) is a subset of the properties of the given entity and a subset of the properties of the direct and indirect master entities (in terms of the master-detail relationship).
- From the point of view of Sql constructions, for a given entity (table) View (or ModelView) is an sql View.
- To Add a View to the project
- Run Visual Studio and Open “PhonebookSolution” solution
- Right Click “PhBk” of the “PhBkViews”-project and select “ModelView Wizard” menu item to open the Wizard dialog
Click to show the picture
- 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
- 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.
Click to show the picture
- On the third page of the Wizard we select Entity for the View. Choose
PhBkEntity.csproj
andPhbkPhoneType
-class and clickNext
-button
Click to show the picture
- On the fourth page of the Wizard we can select existing view to modify or import View-definition from another Repo. Since we have not any Views we just create
Next
-button.
Click to show the picture
- On the fifth page of the Wizard we define subset of properties, we turn on
Jenerate JsonProperty Attribute
-CheckBox, weTitle
andPlural Title
for the given view. ClickNext
-button.
Click to show the picture
- On the Sixth page of the Wizard we choose
ViewModel.cs.t4
T4-template to generate the code. ClickNext
-button.
Click to show the picture
- On the Seventh page of the Wizard click
Save
-button. ClickNext
-button.
Click to show the picture
The PhbkPhoneTypeView.cs
will be created in the PhBk
-folder of the PhBkViews.csproj
-project
Click to show the code
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Linq.Expressions;
namespace PhBkViews.PhBk {
public class PhbkPhoneTypeView {
[Required]
[Display(Description="Row id",Name="Phone Type Id",Prompt="Enter Phone Type Id",ShortName="Phone Type Id")]
public System.Int32 phoneTypeId { get; set; }
[Required]
[StringLength(20,MinimumLength=3,ErrorMessage="Invalid")]
[Display(Description="Name of the Phone Type",Name="Phone Type Name",Prompt="Enter Phone Type Name",ShortName="Phone Type Name")]
public System.String phoneTypeName { get; set; } = null!;
[Display(Description="Description of the Phone Type",Name="Phone Type Description",Prompt="Enter Phone Type Description",ShortName="Phone Type Description")]
[StringLength(250,ErrorMessage="Invalid")]
public System.String ? phoneTypeDesc { get; set; }
}
}
- On the Eighth page of the Wizard choose
ViewModelPage.cs.t4
-T4-template and clickNext
-button.
Click to show the picture
- On the Ninth page of the Wizard click
Save
-button and close the wizard.
Click to show the picture
The PhbkPhoneTypeViewPage.cs
will be created in the PhBk
-folder of the PhBkViews.csproj
-project
Click to show the code
//using System;
//using System.Collections.Generic;
//using System.ComponentModel.DataAnnotations;
//using System.Linq;
//using System.Linq.Expressions;
// using Newtonsoft.Json;
// using Newtonsoft.Json.Serialization;
namespace PhBkViews.PhBk {
public class PhbkPhoneTypeViewPage {
public int page { get; set; }
public int pagesize { get; set; }
public int pagecount { get; set; }
public int total { get; set; }
public List<PhbkPhoneTypeView> items { get; set; } = null!;
}
}
- After
Save
-operation in the solution folder the Wizard's repo file will be created(or updated). - A separate repo file is created for each DbContext.
- The repo file is updated only when you click the save button.