public GibsonQuery( IClientService clientService, IEmployeeService employees, ICustomerService customers, IBookingRequestService bookingRequests, IHttpContextAccessor ctx, IAuthService <AuthUser> auth, ICustomerVehicleService vehicles ) { this.httpContext = ctx; this.auth = auth; Name = "Query"; Field <ListGraphType <ClientModel> >("clients", resolve: context => Authenticated() ? clientService.GetClients() : throw new Exception("Not authenticated")); Field <ListGraphType <EmployeeModel> >("employees", resolve: context => Authenticated() ? employees.GetAllUsers(ctx.GetClientKey()) : throw new Exception("Not authenticated")); Field <ListGraphType <CustomerModel> >("customers", resolve: context => Authenticated() ? customers.GetAllUsers(ctx.GetClientKey()) : throw new Exception("Not authenticated")); Field <ListGraphType <BookingRequestModel> >("bookingRequests", resolve: c => Authenticated() ? bookingRequests.GetBookings(ctx.GetAuthToken().GetClientId()) : throw new Exception("Not authenticated")); Field <ListGraphType <CustomerVehicleModel> >("myVehicles", resolve: context => Authenticated() ? vehicles.GetCustomerVehicles(ctx.GetAuthToken().GetUserId(), ctx.GetAuthToken().GetClientId()) : throw new Exception("Not authenticated")); Field <ClientModel>("client", resolve: c => { return(Authenticated() ? clientService.GetClient(ctx.GetAuthToken().GetClientId().ToString()) : throw new Exception("Not authenticated")); }); Field <CustomerModel>("myProfile", resolve: c => Authenticated() ? customers.GetById(ctx.GetAuthToken().GetUserId().ToString(), ctx.GetAuthToken().GetClientId().ToString()) : throw new Exception("Not authenticated")); Field <CustomerModel>("myCustomerProfile", resolve: c => Authenticated() ? customers.GetById(ctx.GetAuthToken().GetUserId().ToString(), ctx.GetAuthToken().GetClientId().ToString()) : throw new Exception("Not authenticated")); Field <EmployeeModel>("myEmployeeProfile", resolve: c => Authenticated() ? employees.GetByJwtToken(ctx.GetAuthToken()) : throw new Exception("Not authenticated")); Field <CustomerVehicleModel>("vehicle", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "vehicleId" }), resolve: c => { return(Authenticated() ? vehicles.GetCustomerVehicle(Guid.Parse(c.GetArgument <string>("vehicleId")), ctx.GetAuthToken().GetClientId()) : throw new Exception("Not authenticated")); }); Field <CustomerModel>("customer", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "customerId" }), resolve: c => { return(Authenticated() ? customers.GetById(c.GetArgument <string>("customerId"), ctx.GetClientKey()) : null); }); Field <BookingRequestModel>("bookingRequest", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "bookingId" }), resolve: c => { return(Authenticated() ? bookingRequests.GetBooking(Guid.Parse(c.GetArgument <string>("bookingId")), ctx.GetAuthToken().GetClientId()) : throw new Exception("Not authenticated")); }); Field <ClientModel>("clientByKey", arguments: new QueryArguments(new QueryArgument <StringGraphType> { Name = "shortKey" }), resolve: c => { return(Authenticated() ? clientService.GetClientByShortKey(c.GetArgument <string>("shortKey")) : throw new Exception("Not authenticated")); }); }
public CustomerController(ICustomerService customerService, ICommentService commentService, ICustomerVehicleService customerVehicleService, ISessionService sessionService, IMapper mapper, ILog4Net logger, IUserService userService) { _customerService = customerService; _commentService = commentService; _customerVehicleService = customerVehicleService; _sessionService = sessionService; _mapper = mapper; _logger = logger; _userService = userService; }
public CustomerModel(IBookingRequestService bookings, ICustomerVehicleService vehicles) { Field(e => e.Id); Field(e => e.FirstName); Field(e => e.LastName); Field(e => e.AgreedToTerms); Field(e => e.ContactNumber, true); Field(e => e.Disabled); Field(e => e.EmailAddress); Field(e => e.ProviderId, true); Field(e => e.ProviderName, true); Field(e => e.Username); Field <ListGraphType <BookingRequestModel> >("bookings", resolve: c => bookings.GetBookingsByCustomer(Guid.Parse(c.Source.Id), Guid.Parse(c.Source.ClientId.Id))); Field <ListGraphType <CustomerVehicleModel> >("vehicles", resolve: c => vehicles.GetCustomerVehicles(Guid.Parse(c.Source.Id), Guid.Parse(c.Source.ClientId.Id))); Field <MarketingNotificationPreferencesModel>("marketingPreferences", resolve: c => c.Source.CustomerData.MarketingPreferences); Field <CustomerNotificationPreferencesModel>("notificationPreferences", resolve: c => c.Source.CustomerData.NotificationPreferences); }
public MyVehiclesController(ICustomerVehicleService vehicleService, IVehicleDataService vehicleData, IClientService clientService) { this.vehicleService = vehicleService; this.vehicleData = vehicleData; _clientService = clientService; }