public QueryArguments GetArguments() { return(new QueryArguments(new List <QueryArgument> { GraphQLHelper.NewArgument <StringGraphType>(HrCode, "HrCode") })); }
public DetailCodeQuery(IDetailCodeRepository _detailCodeRepository, IDetailCodeOrch _detailCodeOrch) { detailCodeRepository = _detailCodeRepository; detailCodeOrch = _detailCodeOrch; Field <ListGraphType <CountryType> >( "Countries", arguments: new CountryArguments(), resolve: context => { var criteria = context.Arguments.GetPropertyValue <DetailCodeSearchCriteria>(); var props = GraphQLHelper.GetRequestedFields(context); var countries = detailCodeRepository.GetCountries(criteria, props); return(countries); }); Field <ListGraphType <CityType> >( "Cities", arguments: new CityArguments(), resolve: context => { var criteria = context.Arguments.GetPropertyValue <DetailCodeSearchCriteria>(); var props = GraphQLHelper.GetRequestedFields(context); var cities = detailCodeRepository.GetCities(criteria, props); return(cities); }); }
public async Task <ActionResult> Orders() { GraphQLQuery graphQLQuery = GraphQLHelper.GetGraphQLQuery("GetAllOrders"); var heroRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "GetAllOrders" }; var graphQLClient = new GraphQLClient("http://localhost:13515/api/school"); var graphQLResponse = await graphQLClient.PostAsync(heroRequest); string json = JsonConvert.SerializeObject(graphQLResponse.Data); var result = JsonConvert.DeserializeObject <Dictionary <string, OrdersVm> >(json); List <Order> orders = new List <Order>(); OrdersVm ordersVm = new OrdersVm(); foreach (var obj in result.Values.ElementAt(0).Orders) { orders.Add(obj); } ordersVm.Orders = orders; ordersVm.OrdersCount = result.Values.ElementAt(0).OrdersCount; //var result = JsonConvert.DeserializeObject<Dictionary<string, List<Order>>>(json); //List<Order> orders = new List<Order>(); //foreach (var obj in result.Values.ElementAt(0)) //{ // orders.Add(obj); //} return(View(ordersVm)); }
public QueryArguments GetInputArguments() { return(new QueryArguments(new List <QueryArgument> { GraphQLHelper.NewArgument <NonNullGraphType <StringGraphType> >("hrCode", "HrCode"), GraphQLHelper.NewArgument <NonNullGraphType <LessonPlanInputType> >("lessonPlanInput", "教案输入参数") })); }
public async Task <ActionResult> CreateOrder() { CreateOrderVm createOrderVm = new CreateOrderVm(); //get customers var graphQLClient = new GraphQLClient("http://localhost:13515/api/school"); GraphQLQuery graphQLQuery = GraphQLHelper.GetGraphQLQuery("GetCustomers"); var heroRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "GetAllCustomers" }; var graphQLResponse = await graphQLClient.PostAsync(heroRequest); string json = JsonConvert.SerializeObject(graphQLResponse.Data); var result = JsonConvert.DeserializeObject <Dictionary <string, List <Customer> > >(json); List <Customer> customers = new List <Customer>(); foreach (var obj in result.Values.ElementAt(0)) { customers.Add(obj); } createOrderVm.Customers = customers; //get employees graphQLQuery = GraphQLHelper.GetGraphQLQuery("GetEmployees"); heroRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "GetAllEmployees" }; graphQLResponse = await graphQLClient.PostAsync(heroRequest); json = JsonConvert.SerializeObject(graphQLResponse.Data); var result2 = JsonConvert.DeserializeObject <Dictionary <string, List <Employee> > >(json); List <Employee> employees = new List <Employee>(); foreach (var obj in result2.Values.ElementAt(0)) { employees.Add(obj); } createOrderVm.Employees = employees; //get shippers graphQLQuery = GraphQLHelper.GetGraphQLQuery("GetShippers"); heroRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "GetAllShippers" }; graphQLResponse = await graphQLClient.PostAsync(heroRequest); json = JsonConvert.SerializeObject(graphQLResponse.Data); var result3 = JsonConvert.DeserializeObject <Dictionary <string, List <Shipper> > >(json); List <Shipper> shippers = new List <Shipper>(); foreach (var obj in result3.Values.ElementAt(0)) { shippers.Add(obj); } createOrderVm.Shippers = shippers; return(View(createOrderVm)); }
public QueryArguments GetArguments() { return(new QueryArguments(new List <QueryArgument> { GraphQLHelper.NewArgument <StringGraphType>(LessonId, "课程Id"), GraphQLHelper.NewArgument <DateGraphType>(StartDate, "起始日期"), GraphQLHelper.NewArgument <DateGraphType>(EndDate, "结束日期") })); }
public async Task <ActionResult> DeleteOrder(int orderId) { GraphQLQuery graphQLQuery = GraphQLHelper.GetGraphQLQuery("DeleteOrder"); var graphQLRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "DeleteOrder", Variables = new { orderId = orderId } }; var graphQLClient = new GraphQLClient("http://localhost:13515/api/school"); var graphQLResponse = await graphQLClient.PostAsync(graphQLRequest); string json = JsonConvert.SerializeObject(graphQLResponse.Data); var result = JsonConvert.DeserializeObject <Dictionary <string, int> >(json); return(RedirectToAction("Orders")); }
public async Task <ActionResult> EditOrder(int orderId) { GraphQLQuery graphQLQuery = GraphQLHelper.GetGraphQLQuery("GetOrderById"); var graphQLRequest = new GraphQLRequest { Query = graphQLQuery.Body, OperationName = "GetOrderById", Variables = new { orderId = orderId } }; var graphQLClient = new GraphQLClient("http://localhost:13515/api/school"); var graphQLResponse = await graphQLClient.PostAsync(graphQLRequest); string json = JsonConvert.SerializeObject(graphQLResponse.Data); var result = JsonConvert.DeserializeObject <Dictionary <string, Order> >(json); return(View(result.Values.ElementAt(0))); }
public async Task <ActionResult> EditOrder(Order order) { order.Order_Details = null; GraphQLQuery graphQLMutation = GraphQLHelper.GetGraphQLQuery("EditOrder"); var graphQLRequest = new GraphQLRequest { Query = graphQLMutation.Body, OperationName = "EditOrder", Variables = new { orderParam = order } }; var graphQLClient = new GraphQLClient("http://localhost:13515/api/school"); var graphQLResponse = await graphQLClient.PostAsync(graphQLRequest); string json = JsonConvert.SerializeObject(graphQLResponse.Data); var result = JsonConvert.DeserializeObject <Dictionary <string, Order> >(json); return(RedirectToAction("OrderDetails", new { orderId = result.Values.ElementAt(0).OrderID })); }
public AppResourceQuery(IAppResourceRepository _appResourceRepository, IAppResourceOrch _appResourceOrch) { appResourceRepository = _appResourceRepository; appResourceOrch = _appResourceOrch; Field <ListGraphType <AppResourceType> >( "AppResource", arguments: new AppResourceArguments(), resolve: context => { var criteria = context.Arguments.GetPropertyValue <AppResourceSearchCriteria>(); var props = GraphQLHelper.GetRequestedFields(context); var appResources = appResourceRepository.GetAsQueryable(criteria).SelectProps <AppResource, AppResourceDTO>(props).ToList(); return(appResources); }); }