Beispiel #1
0
        public async Task <IActionResult> RemoveDriver(int ownerId, int raceId, int driverId)
        {
            var command = new RemoveDriverFromRacePickCommand(ownerId, raceId, driverId);
            var result  = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
        internal ActionResult <AxisRatesResponse> ProcessRequest(Func <IAxisRates> Request, uint TransactionID, uint ClientID = 0, uint ClientTransactionID = 0, string Payload = "")
        {
            try
            {
                LogAPICall(HttpContext.Connection.RemoteIpAddress, HttpContext.Request.Path.ToString(), ClientID, ClientTransactionID, TransactionID, Payload);

                var rates = Request.Invoke();

                IList <AxisRate> res = new List <AxisRate>();

                foreach (IRate rate in rates)
                {
                    res.Add(new AxisRate(rate.Minimum, rate.Maximum));
                }

                return(Ok(new AxisRatesResponse()
                {
                    ClientTransactionID = ClientTransactionID,
                    ServerTransactionID = TransactionID,
                    Value = res
                }));
            }
            catch (DeviceNotFoundException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                return(Ok(ResponseHelpers.ExceptionResponseBuilder <AxisRatesResponse>(ex, ClientTransactionID, TransactionID)));
            }
        }
Beispiel #3
0
        public async Task <IActionResult> DeleteRacePick(int ownerId, int raceId)
        {
            var command = new DeleteRacePickCommand(ownerId, raceId);
            var result  = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
        public async Task<ActionResult> DeleteDriverRaceEntry(int raceId, int driverId)
        {
            var command = new DeleteDriverRaceEntryCommand(raceId, driverId);
            var result = await _mediator.Send(command);

            return ResponseHelpers.BuildNoContentResponse(this, result);
        }
Beispiel #5
0
        public async Task <ActionResult <GetRacePickByIdVm> > GetRacePick(int ownerId, int raceId)
        {
            var query  = new GetRacePicksByIdQuery(ownerId, raceId);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
        public async Task <ActionResult <GetAllRiderRaceEntriesVm> > GetRiderRaceEntries(int raceId)
        {
            var query  = new GetAllRiderRaceEntriesQuery(raceId);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
Beispiel #7
0
        public async Task <ActionResult <GetOwnerByIdVm> > GetOwner(int id)
        {
            var query  = new GetOwnerByIdQuery(id);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
Beispiel #8
0
        public async Task <IActionResult> DeleteOwner(int id)
        {
            var command = new DeleteOwnerCommand(id);
            var result  = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
        public async Task <IActionResult> RemoveRider(int fantasyTeamId, int raceId, int riderId)
        {
            var command = new RemoveRiderFromFantasyTeamRaceEntryCommand(fantasyTeamId, raceId, riderId);
            var result  = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
Beispiel #10
0
        public async Task <ActionResult <GetAllFantasyTeamsVm> > GetFantasyTeams()
        {
            var query  = new GetAllFantasyTeamsQuery();
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
        public void MissingCookiesValidXSRFTokenUnauthTest()
        {
            // get a paired client and xsrf token
            var clientxsrf = ClientXsrf.GetValidClientAndxsrfTokenPair(_configure);

            // extract the client
            var client = clientxsrf.client;

            // give client empty cookie containter
            client.CookieContainer = new System.Net.CookieContainer();

            // extract the xsrf token
            var xsrfToken = clientxsrf.xsrfToken;

            // set the uri for the authorised api request
            client.BaseUrl = new Uri($"{_configure.BaseUrl}/api/account/me");

            //setup the request
            var request = RequestHelpers.BasicPostRequest();

            //get the authorization token and adds the token to the request
            request.AddHeader("X-XSRF-TOKEN", xsrfToken);

            // we don't expect out result to be valid as we have no valid cookies,
            // even though we have attatched a valid xsrf token as a header.
            // check response
            ResponseHelpers.CheckResponse(client, request, expectValid: false);
        }
        public async Task <ActionResult <GetRaceStageByIdVm> > GetRaceStage(int raceId, int stageId)
        {
            var query  = new GetRaceStageByIdQuery(raceId, stageId);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
        public async Task <ActionResult <GetFantasyTeamRaceEntryByIdVm> > GetFantasyTeamRaceEntry(int fantasyTeamId, int raceId)
        {
            var query  = new GetFantasyTeamRaceEntryByIdQuery(fantasyTeamId, raceId);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildRawContentResponse(this, result));
        }
        public async Task<ActionResult> PutDriverRaceEntry(int raceId, int driverId, UpdateDriverRaceEntryCommand command)
        {
            if (command.RaceId != raceId || command.DriverId != driverId) return BadRequest();

            var result = await _mediator.Send(command);

            return ResponseHelpers.BuildNoContentResponse(this, result);
        }
        public async Task<ActionResult> PostDriverRaceEntry(int raceId, CreateDriverRaceEntryCommand command)
        {
            if (command.RaceId != raceId) return BadRequest();

            var result = await _mediator.Send(command);

            return ResponseHelpers.BuildStatusCodeResponse(this, result, 201);
        }
Beispiel #16
0
        public async Task <ActionResult <FantasyTeam> > PostFantasyTeam(CreateFantasyTeamCommand command)
        {
            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildCreatedAtResponse(
                       this,
                       result,
                       nameof(GetFantasyTeam),
                       () => new { id = result.Content.Id }));
        }
Beispiel #17
0
        public async Task <ActionResult <Owner> > PostOwner(CreateOwnerCommand command)
        {
            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildCreatedAtResponse(
                       this,
                       result,
                       nameof(GetOwner),
                       () => new { id = result.Content.Id }));
        }
Beispiel #18
0
        public override Task <RegisterChannelResponse> RegisterChannel(RegisterChannelRequest request, ServerCallContext context)
        {
            var channel  = tracker.AddChannel(request.PeerdId, request.ChannelId);
            var response = new RegisterChannelResponse()
            {
                ResponseStatus = ResponseHelpers.CreateOkStatus()
            };

            return(Task.FromResult(response));
        }
        public async Task <ActionResult <int> > PostRace(CreateRaceCommand race)
        {
            var result = await _mediator.Send(race);

            return(ResponseHelpers.BuildCreatedAtResponse(
                       this,
                       result,
                       nameof(GetRace),
                       () => new { id = result.Content }));
        }
Beispiel #20
0
        public async Task <ActionResult <RacePick> > SetRacePick(int ownerId, SetRacePickCommand command)
        {
            if (command.OwnerId != ownerId)
            {
                return(BadRequest());
            }

            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildStatusCodeResponse(this, result, 200));
        }
        public async Task <ActionResult> UpdateRaceStage(int raceId, int stageId, UpdateRaceStageCommand command)
        {
            if (command.RaceId != raceId || command.Id != stageId)
            {
                return(BadRequest());
            }

            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
        public async Task <ActionResult> PutRiderRaceEntry(int raceId, int riderId, UpdateRiderRaceEntryCommand command)
        {
            if (command.RaceId != raceId || command.RiderId != riderId)
            {
                return(BadRequest());
            }

            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
        public async Task <ActionResult> PostFantasyTeamRaceEntry(int fantasyTeamId, CreateFantasyTeamRaceEntryCommand command)
        {
            if (command.FantasyTeamId != fantasyTeamId)
            {
                return(BadRequest());
            }

            var result = await _mediator.Send(command);

            return(ResponseHelpers.BuildStatusCodeResponse(this, result, 201));
        }
 private Response InvalidOrderOperationHandler(NancyContext ctx, Exception ex)
 {
     if (ex is InvalidOrderOperationException)
     {
         return(ResponseHelpers.BadRequest(null, content: ex.Message));
     }
     else
     {
         return(null);
     }
 }
Beispiel #25
0
        public override Task <RegisterPeerResponse> RegisterPeer(RegisterPeerRequest request, ServerCallContext context)
        {
            var peer     = tracker.AddPeer(request.ServerLocation.Uri, request.ServerLocation.Port);
            var response = new RegisterPeerResponse()
            {
                ResponseStatus = ResponseHelpers.CreateOkStatus(),
                PeerId         = peer.Id
            };

            return(Task.FromResult(response));
        }
        public ResponseHelpers UpdateStatusCole()
        {
            ColegiaturasServices colegiaturasServices = new ColegiaturasServices();

            var respuesta = new ResponseHelpers();

            respuesta.Message = "Ha ocurrido un error inesperado";

            int Successful = 0;
            int Error      = 0;

            DateTime HoraDelServidor = DateTime.Now;
            DateTime hoy             = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(HoraDelServidor, TimeZoneInfo.Local.Id, "Eastern Standard Time (Mexico)");

            colegiaturasServices.ObtenerFechaColegiaturasATM(hoy);

            if (colegiaturasServices.lsFCAATMViewModel.Count > 0)
            {
                foreach (var item in colegiaturasServices.lsFCAATMViewModel)
                {
                    //respuesta.Data += "Ini" + item.FHInicio + " Lim" + item.FHLimite + " Ven" + item.FHVencimiento + " " + item.EstatusFechaColegiatura + "<br/>";

                    if (colegiaturasServices.ActualizarEstatusFechasPagosATM(item.UidFechaColegiaturaAlumno, item.UidEstatusFechaColegiatura))
                    {
                        Successful++;
                    }
                    else
                    {
                        Error++;
                    }
                }
            }
            else
            {
                respuesta.Message = "01pm1l";
            }

            if (Error > 0 && Successful > 0)
            {
                respuesta.Message = "Successful with errors";
            }

            if (Successful > 0)
            {
                respuesta.Message = "Successful";
            }
            else if (Error > 0)
            {
                respuesta.Message = "Error";
            }

            return(respuesta);
        }
Beispiel #27
0
        public async Task <IActionResult> PutOwner(int id, UpdateOwnerCommand command)
        {
            if (command.Id != id)
            {
                return(BadRequest());
            }

            var query  = new UpdateOwnerCommand(id, command.Name);
            var result = await _mediator.Send(query);

            return(ResponseHelpers.BuildNoContentResponse(this, result));
        }
Beispiel #28
0
        protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {
            if (filterContext.RequestContext.HttpContext.Request.IsAjaxRequest())
            {
                filterContext.HttpContext.Response.AddHeader(AuthenticationRequiredHeaderName, "1");
                filterContext.Result = ResponseHelpers.JsonResult(new
                {
                    authentication_required = true
                });
                return;
            }

            base.HandleUnauthorizedRequest(filterContext);
        }
Beispiel #29
0
        public override Task <GetChannelResponse> GetChannel(GetChannelRequest request, ServerCallContext context)
        {
            var channel  = tracker.GetChannel(request.ChannelId);
            var response = new GetChannelResponse()
            {
                ResponseStatus = ResponseHelpers.CreateOkStatus(),
                ServerLocation = new ServerLocation()
                {
                    Uri  = channel.Peer.Host,
                    Port = channel.Peer.Port
                }
            };

            return(Task.FromResult(response));
        }
Beispiel #30
0
        public async Task <ActionResult <int> > PostTrack(CreateTrackCommand track)
        {
            if (_context.Tracks.Any(e => e.NascarId == track.NascarId))
            {
                return(Conflict());
            }

            var result = await _mediator.Send(track);

            return(ResponseHelpers.BuildCreatedAtResponse(
                       this,
                       result,
                       nameof(GetTrack),
                       () => new { id = result.Content }));
        }