public async Task <ActionResult <AttendeeResponse> > Post(ConferenceDTO.Attendee input) { // Check if the attendee already exists var existingAttendee = await _context.Attendees .Where(a => a.UserName == input.UserName) .FirstOrDefaultAsync(); if (existingAttendee != null) { return(Conflict(input)); } var attendee = new Data.Attendee { FirstName = input.FirstName, LastName = input.LastName, UserName = input.UserName, EmailAddress = input.EmailAddress }; _context.Attendees.Add(attendee); await _context.SaveChangesAsync(); var result = attendee.MapAttendeeResponse(); return(CreatedAtAction(nameof(Get), new { username = result.UserName }, result)); }
public async Task <bool> CreateAttendeeAsync(ConferenceDTO.Attendee attendee) { var response = await _httpClient.PostAsJsonAsync(_attendeesUri, attendee); if (response.StatusCode == HttpStatusCode.Conflict) { return(false); } response.EnsureSuccessStatusCode(); return(true); }
public Task <bool> CreateAttendeeAsync(ConferenceDTO.Attendee attendee) { throw new NotImplementedException(); }