404 First View (PhoneType). Wizard repository. - chempkovsky/CS82ANGULAR GitHub Wiki

Definition

  • 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.

Steps required to accomplish the task

Run ModelViews Wizard
  • To Add a View to the project
    • Run Visual Studio and Open “rupbes.firstapp” solution
    • Create PhBk-subfolder of the rupbes.firstapp.Application.Contracts.csproj-project
    • Right Click PhBk of the rupbes.firstapp.Application.Contracts.csproj-project and select ModelView Wizard menu item to open the Wizard dialog
Click to show the picture

project structure

First page of the Wizard

  • 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

  • On the second page of the Wizard we select DbContext that will be used to choose the entity for the View. Select rupbes.firstapp.EntityFrameworkCore.csproj and the firstappDbContext class using the drop-down lists. Click Next-button.
Click to show the picture

project structure

Third page of the Wizard

  • On the third page of the Wizard we select Entity for the View. Choose rupbes.firstapp.Domain.csproj and PhbkPhoneType-class and click Next-button
Click to show the picture

project structure

Fourth page of the Wizard

  • 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

project structure

Fifth page of the Wizard

  • 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.
  • Note: We do not include TenantId in the dto class. Abp-repo class will do it for us.
Click to show the picture

project structure

Sixth page of the Wizard

  • On the Sixth page of the Wizard we choose AbpViewModel.cs.t4 T4-template to generate the code. Click Next-button.
Click to show the picture

project structure

Seventh page of the Wizard

  • On the Seventh page of the Wizard click Save-button. Click Next-button.
Click to show the picture

project structure

The PhbkPhoneTypeDto.cs will be created in the PhBk-folder of the rupbes.firstapp.Application.Contracts.csproj-project

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

using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;

namespace rupbes.firstapp.PhBk {
    public class PhbkPhoneTypeDto : EntityDto<System.Int32>, IHasConcurrencyStamp {
        [JsonPropertyName("phoneTypeName")]
        [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!;

        [JsonPropertyName("phoneTypeDesc")]
        [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; }

        [JsonPropertyName("concurrencyStamp")]
        [Required]
        [Display(Description="Concurrency Stamp",Name="Concurrency Stamp",Prompt="Enter Concurrency Stamp",ShortName="Concurrency Stamp")]
        [StringLength(40,MinimumLength=0,ErrorMessage="Invalid")]
        public System.String  ConcurrencyStamp { get; set; } = null!;

    }
}

Eighth page of the Wizard

  • On the Eighth page of the Wizard choose AbpViewModelPage.cs.t4-T4-template and click Next-button.
Click to show the picture

project structure

Ninth page of the Wizard

  • On the Ninth page of the Wizard click Save-button and close the wizard.
Click to show the picture

project structure

The PhbkPhoneTypeDtoPage.cs will be created in the PhBk-folder of the rupbes.firstapp.Application.Contracts.csproj-project

Click to show the code
using System.Collections.Generic;

namespace rupbes.firstapp.PhBk {

    public class PhbkPhoneTypeDtoPage {
        public int page { get; set; }
        public int pagesize { get; set; }
        public int pagecount { get; set; }
        public int total { get; set; }
        public List<PhbkPhoneTypeDto> items { get; set; } = null!;
    }

}

Repo file

  • 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.
Click to show the picture

project structure

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