コード例 #1
0
        public async Task <ActionResult <AgentDto> > AddAgent(CreateAgentDto agent)
        {
            var agency = await _agencyRepository.FindByIdAsync(agent.AgencyId);

            if (agency == null)
            {
                return(NotFound());
            }

            var entity = _mapper.Map <Agent>(agent);
            await _repository.CreateAsync(entity);

            var entityDto = _mapper.Map <AgentDto>(entity);

            return(Ok(entityDto));
        }
コード例 #2
0
 /// <summary>
 /// Get agency by name
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public async Task <AgencyResponseModel> GetAgencyByIdAsync(int id, CancellationToken ct = default)
 {
     return(_mapper.Map <AgencyResponseModel>(await _agencyRepository.FindByIdAsync(id, ct)));
 }