Creating Lookup Tables

Let’s start by creating lookup tables we’ll need.

Here is a list of these tables:

  • Meeting Types (Board Meeting, Weekly Analytics, SCRUM Meeting, Annual Meeting, so on…)
  • Locations (where meeting will be held, room numbers, address etc.)
  • Agenda Types (what subject(s) an agenda is about, might be multiple)
  • Units (which unit is organizing the meeting)
  • Contacts (people which would attend meetings, reporters, managers etc.)

We’ll use database schema met for tables.

Create a new migration under, Modules/Common/Migrations/DefaultDB with name DefaultDB_20160709_232400_MeetingLookups:

  1. using FluentMigrator;
  2. namespace MeetingManagement.Migrations.DefaultDB
  3. {
  4. [Migration(20160709232400)]
  5. public class DefaultDB_20160709_232400_MeetingLookups
  6. : AutoReversingMigration
  7. {
  8. public override void Up()
  9. {
  10. Create.Schema("met");
  11. Create.Table("AgendaTypes").InSchema("met")
  12. .WithColumn("AgendaTypeId").AsInt32()
  13. .Identity().PrimaryKey().NotNullable()
  14. .WithColumn("Name").AsString(100).NotNullable();
  15. Create.Table("Contacts").InSchema("met")
  16. .WithColumn("ContactId").AsInt32()
  17. .Identity().PrimaryKey().NotNullable()
  18. .WithColumn("Title").AsString(30).Nullable()
  19. .WithColumn("FirstName").AsString(50).NotNullable()
  20. .WithColumn("LastName").AsString(50).NotNullable()
  21. .WithColumn("Email").AsString(100).NotNullable();
  22. Create.Table("Locations").InSchema("met")
  23. .WithColumn("LocationId").AsInt32()
  24. .Identity().PrimaryKey().NotNullable()
  25. .WithColumn("Name").AsString(100).NotNullable()
  26. .WithColumn("Address").AsString(300).Nullable()
  27. .WithColumn("Latitude").AsDouble()
  28. .WithColumn("Longitude").AsDouble();
  29. Create.Table("MeetingTypes").InSchema("met")
  30. .WithColumn("MeetingTypeId").AsInt32()
  31. .Identity().PrimaryKey().NotNullable()
  32. .WithColumn("Name").AsString(100).NotNullable();
  33. Create.Table("Units").InSchema("met")
  34. .WithColumn("UnitId").AsInt32()
  35. .Identity().PrimaryKey().NotNullable()
  36. .WithColumn("Name").AsString(100).NotNullable();
  37. }
  38. }
  39. }

Generating Code for Lookup Tables

Our module name will be Meetings. We should use non-plural entity identifiers for generated code:

  • AgendaTypes => AgendaType
  • Contacts => Contact
  • Locations => Location
  • MeetingTypes => MeetingType
  • Units => Unit

Generate code for these 5 tables using the entity identifiers given above:

Sergen Lookups

Generated interface for these tables is fine enough. Just need to do a few cosmetic touches.

Initial Lookups

Open AgendaTypePage.cs, ContactPage.cs, LocationPage.cs, MeetingTypePage.cs and UnitPage.cs files and move navigation links at top of them to NavigationItems.cs:

  1. using Serenity.Navigation;
  2. using Administration = MeetingManagement.Administration.Pages;
  3. using Meeting = MeetingManagement.Meeting.Pages;
  4. [assembly: NavigationLink(1000, "Dashboard",
  5. url: "~/", permission: "", icon: "icon-speedometer")]
  6. [assembly: NavigationMenu(2000, "Meeting")]
  7. [assembly: NavigationLink(2500, "Meeting/Agenda Types",
  8. typeof(Meeting.AgendaTypeController))]
  9. [assembly: NavigationLink(2600, "Meeting/Contacts",
  10. typeof(Meeting.ContactController))]
  11. [assembly: NavigationLink(2700, "Meeting/Locations",
  12. typeof(Meeting.LocationController))]
  13. [assembly: NavigationLink(2800, "Meeting/Meeting Types",
  14. typeof(Meeting.MeetingTypeController))]
  15. [assembly: NavigationLink(2900, "Meeting/Units",
  16. typeof(Meeting.UnitController))]

Setting DisplayName and InstanceName Attributes of Lookup Tables

Open AgendaTypeRow.cs, ContactRow.cs, LocationRow.cs, MeetingTypeRow.cs and UnitRow.cs files and change DisplayName and InstanceName attributes like below:

  • AgendaTypeRow => “Agenda Types”, “Agenda Type”
  • ContactRow => “Contacts”, “Contact”
  • LocationRow => “Locations”, “Location”
  • MeetingTypeRow => “Meeting Types”, “Meeting Type”
  • UnitRow => “Units”, “Unit”
  1. [ConnectionKey("Default"), TwoLevelCached,
  2. DisplayName("Agenda Types"), InstanceName("Agenda Type")]
  3. [ReadPermission("Meeting")]
  4. [ModifyPermission("Meeting")]
  5. public sealed class AgendaTypeRow : Row, IIdRow, INameRow
  6. {