Exemplo n.º 1
0
    public async Task <Attendee> AddAttendee(string fullName, string email, int?age, string phone,
                                             string residentialAddress, Gender?gender, bool returnedInLastTenDays, bool liveWithCovidCaregivers,
                                             bool caredForSickPerson, MultiChoice?haveCovidSymptoms, int?seatNumber)
    {
        var normalizedEmail = email?.ToLowerInvariant();
        var attendee        = new Attendee(normalizedEmail, fullName, age, phone, residentialAddress, gender,
                                           returnedInLastTenDays, liveWithCovidCaregivers, caredForSickPerson, haveCovidSymptoms);

        if (seatNumber.HasValue)
        {
            attendee.UpdateSeatNumber(seatNumber);
        }

        if (!attendee.CanRegister())
        {
            throw new InvalidOperationException("You cannot reserve a seat at this time.");
        }

        await attendee.SaveAsync();

        return(attendee);
    }