public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, HttpMethods.Get, Route = "search/{id:guid}")] HttpRequest req,
            string id)
        {
            var result = await _applicationSearchHandler.GetById(new GetApplicationByIdQuery(id));

            if (!result.Success)
            {
                return(new NotFoundResult());
            }

            return(new OkObjectResult(result.Value));
        }
Ejemplo n.º 2
0
        public async Task Handle(ApplicationCategoryNameChangedEvent applicationCategoryNameChangedEvent)
        {
            _logger.LogInformation($"{nameof(ApplicationCategoryNameChangedEvent)} with id: {applicationCategoryNameChangedEvent.Id}, processing started");
            var applicationGetResult = await _applicationSearchHandler.GetById(new GetApplicationByIdQuery(applicationCategoryNameChangedEvent.Id));

            if (!applicationGetResult.Success)
            {
                _logger.LogInformation($"{nameof(Events.ApplicationCategoryNameChangedEvent)}: application with id: {applicationCategoryNameChangedEvent.Id} cannot be found");
                return;
            }

            var application = applicationGetResult.Value;

            application.Category = applicationCategoryNameChangedEvent.NewCategoryName;
            await _searchableApplicationIndexer.Index(application);

            _logger.LogInformation($"{nameof(Events.ApplicationCategoryNameChangedEvent)} with id: {applicationCategoryNameChangedEvent.Id}, processing finished");
        }