示例#1
0
        public IActionResult GetTrail()
        {
            var objList = _Trailrepo.GetTrail().ToList();
            var mapeo   = _mapper.Map <List <TrailDTO> >(objList);

            return(Ok(mapeo));
        }
示例#2
0
        public IActionResult GetTrail(int trailId)
        {
            var trail = _trailRepo.GetTrail(trailId);

            if (trail == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <TrailDto>(trail)));
        }
示例#3
0
        public IActionResult GetTrail(int id)
        {
            var trail = _repo.GetTrail(id);

            if (trail is null)
            {
                return(NotFound("Not found message"));
            }
            return(Ok(_mapper.Map <TrailDto>(trail)));
        }
        public IActionResult GetTrail(int id)
        {
            var trail = _mapper.Map <TrailDto>(_trailRepository.GetTrail(id));

            if (trail == null)
            {
                return(NotFound());
            }
            return(Ok(trail));
        }
        public IActionResult GetTrails()
        {
            var objList = _trailRepository.GetTrail();
            var objDto  = new List <TrailDto>();

            foreach (var obj in objList)
            {
                objDto.Add(_mapper.Map <TrailDto>(obj));
            }
            return(Ok(objDto));
        }
示例#6
0
        public IActionResult GetTrail(int TrailId)
        {
            Trail Trail = _trailRepo.GetTrail(TrailId);

            if (Trail == null)
            {
                return(NotFound());
            }
            TrailDto TrailDto = _mapper.Map <TrailDto>(Trail);

            return(Ok(TrailDto));
        }
示例#7
0
        public IActionResult GetTrail(int trailId)
        {
            var trailobj = _trailRepository.GetTrail(trailId);

            if (trailobj == null)
            {
                return(NotFound());
            }
            var trailObjDto = _mapper.Map <TrailDto>(trailobj);

            return(Ok(trailObjDto));
        }
        public IActionResult GetTrail(int trailId)
        {
            var obj = _trailRepo.GetTrail(trailId);

            if (obj == null)
            {
                return(NotFound());
            }
            TrailDTO objDTO = _mapper.Map <TrailDTO>(obj);

            return(Ok(objDTO));
        }
示例#9
0
        public IActionResult GetTrail(int trailId)
        {
            var trail = _trailRepository.GetTrail(trailId);

            if (trail == null)
            {
                return(NotFound());
            }
            var mappedTrail = _mapper.Map <TrailDto>(trail);

            return(Ok(mappedTrail));
        }
示例#10
0
        public IActionResult GetTrail(int id)
        {
            var Trail = TrailRepository.GetTrail(id);

            if (Trail == null)
            {
                return(NotFound());
            }

            var natParkDto = mapper.Map <TrailsDto>(Trail);

            return(Ok(natParkDto));
        }
示例#11
0
        public IActionResult GetTrail(int TrailId)
        {
            var Obj = trailRepository.GetTrail(TrailId);

            if (Obj == null)
            {
                return(NotFound());
            }

            var ObjDTO = mapper.Map <TrailDTO>(Obj);

            return(Ok(ObjDTO));
        }
示例#12
0
        public IActionResult GetTrail(int id)
        {
            var obj = _repo.GetTrail(id);

            if (obj == null)
            {
                return(NotFound());
            }

            var objDto = _mapper.Map <TrailDto>(obj);

            return(Ok(objDto));
        }
示例#13
0
        public IActionResult GetTrail(int id)
        {
            var trail = _trailRepo.GetTrail(id);

            if (trail == null)
            {
                return(NotFound());
            }

            var trailDto = _mapper.Map <TrailDto>(trail);

            return(Ok(trailDto));
        }
示例#14
0
        public IActionResult GetTrail(int trailId)
        {
            var obj = _trailRepo.GetTrail(trailId);

            if (obj == null)
            {
                return(NotFound());
            }
            else
            {
                var objDto = _mapper.Map <TrailDto>(obj);
                return(Ok(objDto));
            }
        }
        [Authorize(Roles = "Admin")] // 12. Part 13
        public IActionResult GetTrail(int trailId)
        {
            var trail = trailRepository.GetTrail(trailId);

            if (trail == null)
            {
                return(NotFound());
            }

            // Convert Trail object (Domain Model) to TrailDto (Dto)
            var trailDto = mapper.Map <TrailDto>(trail);

            return(Ok(trailDto));
        }
示例#16
0
        public IActionResult GetTrail(int trailId)
        {
            var domainObject = _repository.GetTrail(trailId);

            if (domainObject == null)
            {
                return(NotFound());
            }

            var dtoItem = _mapper.Map <TrailDto>(domainObject);


            return(Ok(dtoItem));
        }
示例#17
0
        public IActionResult GetTrail(int id)
        {
            var trail = _tRepository.GetTrail(id);

            if (trail != null)
            {
                var trailDTO = _mapper.Map <TrailDTO>(trail);

                return(Ok(trailDTO));
            }
            else
            {
                return(NotFound(new { message = "There is no data" }));
            }
        }
示例#18
0
        public IActionResult GetTrail(int trailId)
        {
            var obj = _trailRepo.GetTrail(trailId);

            //This will ensure we send our Dto instead of the model
            var objDto = new List <TrailDto>();

            if (obj == null)
            {
                return(NotFound());
            }

            objDto.Add(_mapper.Map <TrailDto>(obj));

            return(Ok(objDto));
        }
示例#19
0
        public IActionResult GetTrail(int trailId)
        {
            var obj = _trailRepo.GetTrail(trailId);

            if (obj == null)
            {
                return(NotFound());
            }
            var objDto = _mapper.Map <TrailDto>(obj);

            //var objDto = new TrailDto()
            //{
            //    Created = obj.Created,
            //    Id = obj.Id,
            //    Name = obj.Name,
            //    State = obj.State
            //};

            return(Ok(objDto));
        }
        public IActionResult ShowTrail(int id)
        {
            //use previous api results stored in memory to render details of individual trails -- later can add fallback to ping api with trail id
            var trail = _repository.GetTrail(id);

            if (trail == null)
            {
                return(RedirectToAction("GetFromApi", new { id }));
            }

            return(View(trail));
        }
        public IActionResult GetTrail(int trailId)
        {
            var obj = _trailRepo.GetTrail(trailId);

            if (obj == null)
            {
                return(NotFound());
            }
            var objDto = _mapper.Map <TrailDto>(obj);


            //WITH OUT AUTO MAPPER THIS IS THE CODE U'LL WRITE BELOW
            //var objDto = new TrailDto()
            //{
            //	Created = obj.Created,
            //	Id = obj.Id,
            //	Name = obj.Name,
            //	State = obj.State
            //};

            return(Ok(objDto));
        }
示例#22
0
        public IActionResult GetTrailById(int trailId)
        {
            var da = trailRepository.GetTrail(trailId);


            if (da == null)
            {
                return(BadRequest());
            }

            var objdto = mapper.Map <TrailDTO>(da);

            //var d = new NationalPark
            //{
            //    Created = da.Created,
            //    Established = da.Established,
            //    Id = da.Id,
            //    Name = da.Name,
            //    State = da.State
            //};

            return(Ok(objdto));
        }
示例#23
0
        public async Task <IActionResult> GetTrail(int trailId)
        {
            try
            {
                var trail = await repository.GetTrail(trailId);

                return(Ok(trail));
            }
            catch (ArgumentNullException e)
            {
                var paramName = e.ParamName;
                if (paramName != null)
                {
                    return(NotFound(paramName));
                }

                throw;
            }
        }