Skip to main content

Dialogs & validation

The Create / Edit ticket workflow from Module 5 · Dialogs, Validation & Workflows, as the walkthrough video builds it: one TicketDialog for both New and Edit, ValidateForm() that keeps the dialog open until the required fields are filled, a Save that returns DialogResult.OK, and a Tickets window that saves through TicketService and refreshes the grid only after a successful save.

Run it

cd "LearnWisej-Samples/Foundations Course/Module 5/WisejTrainingApp"
dotnet run -f net10.0 --urls http://localhost:5085

Then open http://localhost:5085. (Visual Studio: open WisejTrainingApp.slnx, press F5.)

What to try

ActionWhat you should see
New Ticket, leave Title empty, SavePlease enter a title. — the dialog stays open
Fill Title and Status, Savethe dialog closes, the new ticket appears in the grid, Ticket created.
Select a row, Edit Ticket, change a field, Savethe grid row updates, Ticket saved.
Cancel in the dialognothing is saved, the grid is unchanged

Where things live

FileWhat it's for
Models/Ticket.csThe shape of one ticket
Services/TicketService.csGetTickets, AddTicket, UpdateTicket, DeleteTicket
Dialogs/TicketDialog.csThe dialog: optional Ticket constructor, ValidateForm(), BuildTicketFromFields(), Save / Cancel
TicketsWindow.csbtnNew_Click / btnEdit_Clickawait ShowDialogAsync(), then the service and a grid refresh