public async Task <bool> AddAgentToAgency(AddAgentToAgencyCommand command) { if (command == null) { throw new ArgumentNullException(nameof(command)); } var agency = await _agencyService.GetById(command.AgencyId); var agent = await GetById(command.AgentId); agent.Agencies.Add(agency); var affectedRecordsCount = await _agentRepository.UpdateRecordAsync(agent); return(affectedRecordsCount >= 1); }
public async Task <IActionResult> AddToAgency(AddAgentToAgencyCommand command) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var result = await _agentService.AddAgentToAgency(command); return(Ok(result)); } catch (NotFoundException <Guid> ) { return(NotFound()); } }