Exemplo n.º 1
0
 public CaptainController(ICaptainRepository captainRepository, IShuttleService shuttleService, IDataReplicationService dataReplicationService, IConfiguration config)
 {
     _captainRepository      = captainRepository;
     _shuttleService         = shuttleService;
     _dataReplicationService = dataReplicationService;
     _config = config;
 }
Exemplo n.º 2
0
 public ShuttlesController(IShuttleService shuttleService)
 {
     _shuttleService = shuttleService;
 }
Exemplo n.º 3
0
 public ExportsController(ILogger <ExportsController> logger, IShuttleService shuttleService)
 {
     _logger         = logger;
     _shuttleService = shuttleService;
 }
Exemplo n.º 4
0
 public ShuttlesController(IShuttleService service, ILogger <ShuttlesController> logger)
 {
     _service = service;
     _logger  = logger;
 }
        public ShuttleMutations(IShuttleService service)
        {
            FieldAsync <ActionResponseType>(
                CREATE_REQUEST_ENDPOINT,
                "Creates a new Shuttle",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <ShuttleCreateViewModel> >
            {
                Name = UPDATE_CREATE_ARGUMENT_NAME, Description = "Shuttle Entity to be Created"
            }),
                async context =>
            {
                var shuttle = context.GetArgument <Shuttle>(UPDATE_CREATE_ARGUMENT_NAME);

                try
                {
                    await service.CreateShuttleAsync(shuttle);
                }
                catch (ValidationException e)
                {
                    context.Errors.Add(new ExecutionError(e.Message));
                    return(new ActionResponse(false));
                }
                catch (Exception)
                {
                    context.Errors.Add(new ExecutionError("Server Error"));
                    return(new ActionResponse(false));
                }

                return(new ActionResponse(true, shuttle.Id));
            });

            FieldAsync <ActionResponseType>(
                UPDATE_REQUEST_ENDPOINT,
                "Updates an existing Shuttle",
                new QueryArguments(
                    new QueryArgument <NonNullGraphType <ShuttleUpdateViewModel> >
            {
                Name = UPDATE_CREATE_ARGUMENT_NAME, Description = "Shuttle to be Updated"
            }),
                async context =>
            {
                var shuttle = context.GetArgument <Shuttle>(UPDATE_CREATE_ARGUMENT_NAME);
                try
                {
                    await service.UpdateShuttleAsync(shuttle);
                }
                catch (ValidationException e)
                {
                    context.Errors.Add(new ExecutionError(e.Message));
                    return(new ActionResponse(false));
                }
                catch (Exception)
                {
                    context.Errors.Add(new ExecutionError("Server Error"));
                    return(new ActionResponse(false));
                }

                return(new ActionResponse(true, shuttle.Id));
            });

            FieldAsync <ActionResponseType>(
                DELETE_REQUEST_ENDPOINT,
                "Removes an existing Shuttle",
                new QueryArguments(
                    new QueryArgument <GuidGraphType>
            {
                Name = DELETE_ARGUMENT_NAME, Description = "Shuttle Id used to identify which Shuttle will be deleted"
            }),
                async context =>
            {
                var id = context.GetArgument <Guid>(DELETE_ARGUMENT_NAME);
                try
                {
                    await service.DeleteShuttleAsync(id);
                }
                catch (ValidationException e)
                {
                    context.Errors.Add(new ExecutionError(e.Message));
                    return(new ActionResponse(false));
                }
                catch (Exception)
                {
                    context.Errors.Add(new ExecutionError("Server Error"));
                    return(new ActionResponse(false));
                }

                return(new ActionResponse(true));
            });
        }