Ejemplo n.º 1
0
        public HttpResponseMessage GetJourneyCheckpoints(string journeyId)
        {
            if (journeyId == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("Please enter an ID for the journey")));
            }

            List <Checkpoint> checkpoints = checkpointBusiness.GetJourneyCheckpoints(journeyId);

            if (checkpoints.Count < 1)
            {
                var       message = string.Format("No checkpoints have been created for this journey");
                HttpError err     = new HttpError(message);

                return(Request.CreateResponse(HttpStatusCode.NotFound, err));
            }

            //Iterates through the list of checkpoints and converts each of them to getCheckpoint DataObject
            List <GetCheckpointDto> getCheckpointDtos = new List <GetCheckpointDto>();

            foreach (Checkpoint checkpoint in checkpoints)
            {
                GetCheckpointDto getCheckpointDto = new GetCheckpointDto(checkpoint);
                getCheckpointDtos.Add(getCheckpointDto);
            }

            return(Request.CreateResponse(HttpStatusCode.OK, getCheckpointDtos));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage GetCheckpoint(string journeyId, string checkpointId)
        {
            if (checkpointId == null)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, string.Format("Please enter an ID for the checkpoint")));
            }

            Checkpoint checkpoint = checkpointBusiness.GetCheckpoint(journeyId, checkpointId);

            if (checkpoint == null)
            {
                var       message = string.Format("Checkpoint not found");
                HttpError err     = new HttpError(message);

                return(Request.CreateResponse(HttpStatusCode.NotFound, err));
            }

            GetCheckpointDto getCheckpointDto = new GetCheckpointDto(checkpoint);

            return(Request.CreateResponse(HttpStatusCode.OK, getCheckpointDto));
        }