public async Task <IActionResult> GetEventById([FromQuery] GetEventByIdQuery query) { using (MiniProfiler.Current.Step("Get Event by Id")) { GetEventByIdQueryViewModel model = await _mediator.Send(query); if (model != null) { return(Ok(model)); } throw new NotFoundCustomException("No data found", $"Please check your parameters id: {query.EventId}"); } }
public async Task <GetEventByIdQueryResult> GetEventById(GetEventByIdQuery getEventByIdQuery) { var queryRequest = new QueryRequest() .Statement(@"SELECT e.*, META(e).id, ARRAY_COUNT(e.comments) as commentsCount, OBJECT_CONCAT({'latitude':e.location.lat},{'longitude':e.location.lon}) AS location, OBJECT_CONCAT({'name':r_groups.groupName},{'id':e.groupId},{'organizerId':r_groups.organizerId}) AS `group` FROM `events` e INNER JOIN `events-relations` r_groups ON KEYS 'groups|' || e.groupId WHERE META(e).id = $eventId LIMIT 1;") .AddNamedParameter("$eventId", getEventByIdQuery.EventId.ToString()); var queryResult = await _eventsBucket.QueryAsync <GetEventByIdQueryResult>(queryRequest); if (!queryResult.Success) { throw queryResult.Exception; } var result = queryResult.Rows.FirstOrDefault(); return(result); }