src/fursvp.api/Controllers/EventController.cs
/// <summary>
/// Adds a new member to an Event's signups.
/// </summary>
/// <param name="eventId">The globally unique identifier for the Event.</param>
/// <param name="newMember">The <see cref="NewMemberRequest" /> containing member data to be added.</param>
/// <returns>201 Created on success, 404 Not Found if the Event Id is not found, or 409 Conflict if the member's email address already exists in the event.</returns>
Adds a new member to an Event's signups.
Adds a new member to an Event ' s signups .
[HttpPost]
        [Route("{eventId}/member")]
        public async Task<IActionResult> AddMember(Guid eventId, [FromBody] NewMemberRequest newMember)
        {
            if (newMember == null)
            {
                throw new ArgumentNullException(nameof(newMember));
            }
            var @event = await EventRepositoryRead.GetById(eventId).ConfigureAwait(false);
            if (@event == null)
            {
                return NotFound("Event not found with id " + eventId);
            }
            var member = new Member
            {
                IsAttending = newMember.IsAttending,
                IsOrganizer = newMember.IsOrganizer,
                EmailAddress = newMember.EmailAddress,
                Name = newMember.Name,
            };
            foreach (var response in newMember.FormResponses) 
            {
                member.Responses.Add(response);
            }
            EventService.AddMember(@event, member);
            await EventRepositoryWrite.Update(@event).ConfigureAwait(false);
            try
            {
                Emailer?.Send(new Email
                  {
                      From = new EmailAddress { Address = "noreply@fursvp.com", Name = "Fursvp.com" },
                      To = new EmailAddress { Address = newMember.EmailAddress, Name = newMember.Name },
                      Subject = $"{@event.Name}: Your event registration",
                      PlainTextContent = @$"{newMember.Name}: We've got you on the list! View the event details or review and change your response at Fursvp.com.",
                      HtmlContent = @$"{HttpUtility.HtmlEncode(newMember.Name)}: We've got you on the list! View the event details or review and change your response at <a href=""https:www.fursvp.com"">FURsvp.com</a>.",
                  });
            }
            catch
            {
            }
            return CreatedAtAction(nameof(GetEvent), new { id = @event.Id }, Mapper.MapResponse(@event, DateTimeProvider));
        }
[ HttpPost ] [ Route ( " " ) ] public async Task < IActionResult > AddMember ( Guid eventId , [ FromBody ] NewMemberRequest newMember ) { if ( newMember == null ) { throw new ArgumentNullException ( nameof ( newMember ) ) ; } var @event = await EventRepositoryRead . GetById ( eventId ) . ConfigureAwait ( false ) ; if ( @event == null ) { return NotFound ( " " + eventId ) ; } var member = new Member { IsAttending = newMember . IsAttending , IsOrganizer = newMember . IsOrganizer , EmailAddress = newMember . EmailAddress , Name = newMember . Name , } ; foreach ( var response in newMember . FormResponses ) { member . Responses . Add ( response ) ; } EventService . AddMember ( @event , member ) ; await EventRepositoryWrite . Update ( @event ) . ConfigureAwait ( false ) ; try { Emailer ? . Send ( new Email { From = new EmailAddress { Address = " " , Name = " " } , To = new EmailAddress { Address = newMember . EmailAddress , Name = newMember . Name } , Subject = $" { @event . Name } : Your event registration " , PlainTextContent = @$" { newMember . Name } : We've got you on the list! View the event details or review and change your response at Fursvp.com. " , HtmlContent = @$" { HttpUtility . HtmlEncode ( newMember . Name ) } : We've got you on the list! View the event details or review and change your response at <a href= "" https://www.fursvp.com "" >FURsvp.com</a>. " , } ) ; } catch { } return CreatedAtAction ( nameof ( GetEvent ) , new { id = @event . Id } , Mapper . MapResponse ( @event , DateTimeProvider ) ) ; }
Adds a new member to an Event's signups.
Adds a new member to an Event ' s signups .
// TODO: Get hardcoded strings into config //
201 Created on success, 404 Not Found if the Event Id is not found, or 409 Conflict if the member's email address already exists in the event.
201 Created on success 404 Not Found if the Event Id is not found or 409 Conflict if the member ' s email address already exists in the event .
eventId
Guid
The globally unique identifier for the Event.
The globally unique identifier for the Event .
NewMemberRequest
[FromBody]
newMember
The  containing member data to be added.
The containing member data to be added .