Example #1
0
        public async Task <IActionResult> CreateAgent([FromBody] CreateAgentCommand newAgentRequest)
        {
            var result = await mediator.Send(newAgentRequest);

            return(result ?
                   (IActionResult)Ok(result) :
                   (IActionResult)BadRequest());
        }
Example #2
0
        public async Task <IActionResult> Create(CreateAgentCommand command)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var result = await _agentService.CreateAsync(command);

            return(Created($"/agent/{result.Id}", result));
        }
        public async Task <Agent> CreateAsync(CreateAgentCommand command)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            var agency = _mapper.Map <Agent>(command);
            var result = await _agentRepository.CreateRecordAsync(agency);

            return(result);
        }