418.4 Creating Etos for the Lookup Resource of PhbkDivision of ABP framework applications - chempkovsky/CS82ANGULAR GitHub Wiki
- right click
LpPhBk-folder of therupbes.firstapp.Application.Contracts.csproj-project - in the pop-up menu click Scripts Wizards
Click to show the picture

- on the second page select
firstappDbContext-DbContext
Click to show the picture

- on the third page select
PhbkDivisionDto-dto class
Click to show the picture

- on the fourth page select
01010-.extforlkup-action
Click to show the picture

- on the fifth page select
extforlkup.abp.cs.t4-script
Click to show the picture

- click
nextandsave.phbk-division-dto.extforlkup.cs-file will be saves. - Three classes were generated:
PhbkDivisionEto,PhbkDivisionEtoEx,PhbkDivisionDtoCloneForLkUp -
PhbkDivisionEtoEx-class will be used for sending overEvent-service -
PhbkDivisionEtoEx-class has[EventName("rupbes.firstapp.Phbk.PhbkDivisionEto")]-attribute as suggested -
PhbkDivisionEtoEx-class shows that we use our own structure for pub/sub operations -
TenantId-prop of thePhbkDivisionEtoEx-class is used to support Multitenancy for lookup resources -
TenantId-prop is not defined inPhbkDivisionEto-class which is a data class !!! -
PhbkDivisionDtoCloneForLkUpis used to define a static helper method:DoClone
Click to show the code
#nullable disable
using System.Text.Json.Serialization;
using System.ComponentModel.DataAnnotations;
using Volo.Abp.EventBus;
using System;
using rupbes.firstapp.PhBk;
namespace rupbes.firstapp.LpPhBk {
// [EventName("rupbes.firstapp.Phbk.PhbkDivisionEto")]
public class PhbkDivisionEto {
[JsonPropertyName("id")]
[Required]
[Display(Description="Row id",Name="Id of the Division",Prompt="Enter Division Id",ShortName="Division Id")]
public System.Int32 Id { get; set; }
[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!;
[JsonPropertyName("entrprsIdRef")]
[Required]
[Display(Description="Row id",Name="Id of the Enterprise",Prompt="Enter Enterprise Id",ShortName="Enterprise Id")]
public System.Int32 EntrprsIdRef { get; set; }
}
[EventName("rupbes.firstapp.Phbk.PhbkDivisionEto")]
public class PhbkDivisionEtoEx {
public Guid? TenantId { get; set; } = null!;
// 1 - insert; 2 - update; 3 - delete;
public int Action { get; set; }
public PhbkDivisionEto OldVals { get; set; } = null!;
public PhbkDivisionEto NewVals { get; set; } = null!;
}
public static class PhbkDivisionDtoCloneForLkUp {
public static PhbkDivisionEto DoClone(PhbkDivisionDto src) {
PhbkDivisionEto dest = new PhbkDivisionEto();
if(src != null) {
dest.Id = src.Id;
dest.DivisionName = src.DivisionName;
dest.EntrprsIdRef = src.EntrprsIdRef;
}
return dest;
}
}
}