public async Task <IActionResult> GetAgentProfile([FromQuery(Name = "agent")] string strAgent)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                Agent agent = new Agent(strAgent);

                var person = await _mediator.Send(GetPersonCommand.Create(agent));

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

                if (HttpMethods.IsHead(Request.Method))
                {
                    return(NoContent());
                }

                return(Ok(person));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex));
            }
        }
Esempio n. 2
0
        public async Task <IActionResult> Get([FromBody] PersonModel model)
        {
            var user = await _userManagerWrapper.FindByNameAsync(User.Identity.Name);

            model.UserId = user.Id;
            var getPersonCommand = new GetPersonCommand {
                Person = model
            };
            var sendOptions = new SendOptions();

            sendOptions.SetDestination("LifeManager.People");
            var response = await _endpointInstance.Request <GetResponse>(getPersonCommand, sendOptions).ConfigureAwait(false);

            return(Ok(new { Response = response.People }));
        }
        public async Task Handle(GetPersonCommand message, IMessageHandlerContext context)
        {
            var people = await _peopleService.GetPerson(message.Person);

            await context.Reply(new GetResponse { People = people });
        }