From a list of club records create a unique list of athletes that have a record. Display athletes in a clickable list so as to select that one athlete such that a certificate can be generated on subsequent pages This displays all records in the original list for that athlete.

About

As discussed in previous posts we have developed a Blazor Server app enabling members of a sporting club to nominate themselves for on-the-day tasks assigned by the sporting association when there are athletics meets. The app has also been extended to handle club athletic records putting the onus onto athletes and their coaches to claim records when performed in state, national and international accredited events. There is also an admin level for verifying and accepting claims as well as managing the overall life cycle of a claim form pending through to historical. Club members can view the current records in sortable and a searchable manner. The current list of records can be printed to a PDF file for printing which includes some graphics such as shading. The latest extension is the ability to list all records set by an athlete in any one season as a certificate with similar graphics and saved as a PDF which can then be downloaded by the athlete. This post discusses this latest extension.

The Blazor (Razor) PAGES

Three pages were created for this:

  1. List all athletes who have created a new club record for the season in a clickable manner such that the Id of the selected athlete is forwarded to the second or third page.
  2. Get a list of all records by the forwarded athlete sorted by date. Where the performance for applies to more than one age group, present them in a grouped manner.
  3. Same as the second but when they are grouped as in 2. only one row is listed with the Age Group column listing all age groups. This is for the rare occasion where an athlete has broken records several times over several age groups. This occurred with an Under 13 athlete who broken several records across most age groups a few times. (Records were previously held by her aunt from some time ago!).

Athlete with Records List

The steps here are:

  1. Get ALL records from server.
  2. Select those that are of status Current or Historical
  3. Select those who’s competition date is within the required season’s begin and end dates.
  4. Select a distinct list of members from that:
var list = await _context.RecordResults
    .Include(e => e.Event)
    .Include(e => e.ClubMember);

var members = (from n in recordResults3 select n.ClubMember)
    .Distinct().OrderBy(s => s.Name);

Members =members.ToList();

The Row OnClick event is handled with the following handler:

    async Task OnRowClickHandler(GridRowClickEventArgs args)
    {
        var mevent = (MouseEventArgs)args.EventArgs;
        Member athlete = args.Item as Member;
        string target;
        string filename = $"records-2022-23-{athlete.Name}.pdf";
        await js.InvokeVoidAsync("navigator.clipboard.writeText", filename);
        if(!mevent.ShiftKey)
        {
            target = $"/OpenAndAgeRecords/fetchAthleteRecordsPrint/{athlete.Id}";
        }
        else
        {
            target = $"/OpenAndAgeRecords/fetchAthleteRecordsPrintMulti/{athlete.Id}";
        }
        navigationManager.NavigateTo(target);
    }

Comments

  • The athlete’s Id is forwarded to the second or third page.
  • The use of the Shift key with the OnClick event determines which page is targeted.
  • The filename is generated and pushed to the clipboard. This can then be used(pasted) later when the certificate is is saved as PDF.

This page can only be accessed by Admin such that they can select any athlete to generate a certificate for.

The members list is shown in a Telerik Grid:


 TopicSubtopic
<  Prev:   Nuget updates
   
 This Category Links 
Category:Web Sites Index:Web Sites
  Next: > Club Record Certificate
<  Prev:   Entity Framework Group Summing