public async Task <RabbitResponse> ProcessAsync(string data) { m_logger.LogInformation($"Received {data}"); var response = JsonConvert.DeserializeObject <RobotUpdateResponse>(data); var(_, toUpdate) = await m_robotService.SearchRobotAsync(new Pagination(), new Ordering(), new RobotFilter { Ids = response.Robots.Select(t => t.Id).ToList() }); response.Robots.ForEach(t => { toUpdate.First(x => x.Id.Equals(t.Id)).CurrentStatus = t.CurrentStatus; toUpdate.First(x => x.Id.Equals(t.Id)).CurrentPlanetId = null; }); await m_robotService.UpdateListOfRobotsAsync(toUpdate); return(null); }
public RobotQueries(IRobotService robotService) { FieldAsync <ListRobotsQueryModelType>( SEARCH_REQUEST_ENDPOINT, "Returns a paginated list of Robots", new QueryArguments( new QueryArgument <NonNullGraphType <PagedRequestType> > { Name = PAGINATION_ARGUMENT_NAME, Description = PagedRequestType.Description }, new QueryArgument <NonNullGraphType <OrderedRequestType> > { Name = ORDERING_ARGUMENT_NAME, Description = OrderedRequestType.Description }, new QueryArgument <NonNullGraphType <FilteredRequestType <Robot> > > { Name = FILTERING_ARGUMENT_NAME, Description = FilteredRequestType <Robot> .Description } ), async context => { var pagination = context.GetArgument <Pagination>(PAGINATION_ARGUMENT_NAME); var ordering = context.GetArgument <Ordering>(ORDERING_ARGUMENT_NAME); var filtering = context.GetArgument <RobotFilter>(FILTERING_ARGUMENT_NAME); var(totalCount, items) = await robotService.SearchRobotAsync(pagination, ordering, filtering); try { return(new ListResponse <Robot> { TotalCount = totalCount, Items = items }); } catch (Exception) { context.Errors.Add(new ExecutionError("Server Error")); return(null); } } ); }