public async Task <IActionResult> CreateAttendeeForItemId(string itemId, AttendeeAddViewModel model) { if (!await _itemRepository.ExistItemByIdAsync(itemId)) { return(NotFound()); } var entity = _mapper.Map <Attendee>(model); _attendeeRepository.CreateAttendeeForItemId(itemId, entity); var result = await _attendeeRepository.SaveAsync(); if (!result) { return(BadRequest()); } var returnModel = _mapper.Map <AttendeeViewModel>(entity); return(CreatedAtRoute(nameof(GetAttendeeByIdForItemId), new { itemId, attendeeId = returnModel.Id }, returnModel)); }