public int GeneratePrivateInvite(PrivateInviteDto dto, string token) { var invite = _privateInviteService.Create(dto.PledgeCampaignId, dto.EmailAddress, dto.RecipientName, token); var communication = PrivateInviteCommunication(invite); _communicationService.SendMessage(communication); return(invite.PrivateInvitationId); }
public IHttpActionResult GeneratePrivateInvite([FromBody] PrivateInviteDto dto) { if (!ModelState.IsValid) { var errors = ModelState.Values.SelectMany(val => val.Errors).Aggregate("", (current, err) => current + err.Exception.Message); var dataError = new ApiErrorDto("GeneratePrivateInvite Data Invalid", new InvalidOperationException("Invalid GeneratePrivateInvite Data" + errors)); throw new HttpResponseException(dataError.HttpResponseMessage); } return(Authorized(token => { try { _tripService.GeneratePrivateInvite(dto, token); return Ok(); } catch (Exception exception) { var apiError = new ApiErrorDto("GeneratePrivateInvite Failed", exception); throw new HttpResponseException(apiError.HttpResponseMessage); } })); }