public static AgentInvitationInfo ToAgentInvitationInfo(this SendAgentInvitationRequest data, AgentContext agent) { return(new AgentInvitationInfo(new AgentEditableInfo( data.RegistrationInfo.Title, data.RegistrationInfo.FirstName, data.RegistrationInfo.LastName, data.RegistrationInfo.Position, data.Email), agent.AgencyId, agent.AgentId, data.Email)); }
public async Task Different_ways_should_create_same_invitations() { var sendInvitationRequest = new SendAgentInvitationRequest(It.IsAny <AgentEditableInfo>(), It.IsAny <string>()); await _invitationService.Send(sendInvitationRequest, Agent); await _invitationService.Create(sendInvitationRequest, Agent); Assert.Equal(_userInvitationService.CreatedInvitationInfo.GetType(), _userInvitationService.SentInvitationInfo.GetType()); Assert.Equal(_userInvitationService.CreatedInvitationInfo, _userInvitationService.SentInvitationInfo); }
public async Task <IActionResult> CreateInvitation([FromBody] SendAgentInvitationRequest request) { var(_, isFailure, code, error) = await _agentInvitationService.Create(request, await _agentContextService.GetAgent()); if (isFailure) { return(BadRequest(ProblemDetailsBuilder.Build(error))); } return(Ok(code)); }
public async Task <IActionResult> CreateInvitation([FromBody] SendAgentInvitationRequest request) { var agent = await _agentContextService.GetAgent(); var(_, isFailure, code, error) = await _agentInvitationCreateService.Create(request.ToUserInvitationData(), UserInvitationTypes.Agent, agent.AgentId, agent.AgencyId); if (isFailure) { return(BadRequest(ProblemDetailsBuilder.Build(error))); } return(Ok(code)); }
public async Task <Result> Send(SendAgentInvitationRequest request, AgentContext agent) { var agencyName = (await _counterpartyService.GetAgency(agent.AgencyId, agent)).Value.Name; var messagePayloadGenerator = new Func <AgentInvitationInfo, string, DataWithCompanyInfo>((info, invitationCode) => new AgentInvitationData { AgencyName = agencyName, InvitationCode = invitationCode, UserEmailAddress = info.Email, UserName = $"{info.RegistrationInfo.FirstName} {info.RegistrationInfo.LastName}" }); return(await _invitationService.Send(request.Email, request.ToAgentInvitationInfo(agent), messagePayloadGenerator, _options.MailTemplateId, UserInvitationTypes.Agent)); }
public async Task <Result <string> > Create(SendAgentInvitationRequest request, AgentContext agent) { var invitationInfo = request.ToAgentInvitationInfo(agent); return(await _invitationService.Create(invitationInfo.Email, invitationInfo, UserInvitationTypes.Agent)); }