Example #1
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
            // Status 200 Ok
        }
Example #2
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands([FromQuery] QueryParameters queryParameters)
        {
            var commandItems = _repository.GetAllCommands();

            IQueryable <Command> commands = commandItems.AsQueryable();

            //sort
            if (!string.IsNullOrEmpty(queryParameters.SortBy))
            {
                if (typeof(Command).GetProperty(queryParameters.SortBy) != null)
                {
                    commandItems = commands.OrderByCustom(queryParameters.SortBy, queryParameters.SortOrder);
                }
            }
            //search
            if (!string.IsNullOrEmpty(queryParameters.HowTo))
            {
                commandItems = commandItems.Where(c => c.HowTo.ToLower().Contains(queryParameters.HowTo.ToLower()));
            }
            //paging
            commandItems = commandItems
                           .Skip(queryParameters.Size * (queryParameters.Page - 1))
                           .Take(queryParameters.Size);

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #3
0
        //  public ActionResult<IEnumerable<Command>> GetAllCommands()
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var CommandItems = _repository.GetAllCommands();

            //return Ok(CommandItems);                                           //through Domain model
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(CommandItems)));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            //Map data form model SQL to ViewData before response
            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #5
0
        public async Task <ActionResult <Pagination <IEnumerable <CommandReturnDto> > > > GetAllCommands([FromQuery] CommandParams commandParams)
        {
            IEnumerable <Command> commandItems = new List <Command>();
            int totalItems = 0;

            // TODO: Specification pattern
            if (commandParams.PlatformId.HasValue)
            {
                commandItems = await _repo.GetCommandsByPlatform(
                    (commandParams.PageSize * (commandParams.PageIndex - 1)),
                    commandParams.PageSize,
                    commandParams.PlatformId.GetValueOrDefault());

                totalItems = await _repo.CountAsyncForPlatform(commandParams.PlatformId.GetValueOrDefault());
            }
            else
            {
                commandItems = await _repo.GetAllCommands(
                    (commandParams.PageSize * (commandParams.PageIndex - 1)),
                    commandParams.PageSize);

                totalItems = await _repo.CountAsync();
            }

            var data = _mapper.Map <IEnumerable <CommandReturnDto> >(commandItems);

            return(Ok(new Pagination <CommandReturnDto>(commandParams.PageIndex, commandParams.PageSize, totalItems, data)));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            //Map the commandItems into an IEnumerable of type CommandReadDto
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #7
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = commanderRepo.GetAllCommands();

            // `Ok` will return HTTP response 200
            return(Ok(mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()  // changed to IEnumerable of CommandReadDtos
        {
            //hold results
            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems))); // maps commandItems from our repository to an CommandreadDto
        }
Example #9
0
        [HttpGet]         // indique que cette méthode répond à une requete http
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            // mapper, mets l'objet commandItems dans CommandReadDto
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));          // méthode Ok définie dans controllerBase
        }
Example #10
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        //public ActionResult<IEnumerable<Command>> GetAllCommands()
        {
            var commandsItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandsItems)));
            //return Ok(commandsItems);
        }
        public ActionResult<IEnumerable<CommandReadDto>> GetAllCommands()
        {
            var commands = _repository.GetAllCommands();

            var model = _mapper.Map<IEnumerable<CommandReadDto>>(commands);

            return Ok(model);    //Ok 202
        }
Example #12
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            var mappedValue = _mapper.Map <IEnumerable <CommandReadDto> >(commandItems);

            return(Ok(mappedValue));
        }
        public ActionResult <IEnumerable <Command> > GetAppCommands()
        {
            //Use repository to get our commands
            //Create var to hold our commands
            var commandItems = _repository.GetAllCommands();

            //return ok success
            return(Ok(commandItems));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            //   _logger.LogDebug("CommandController.GetAllCommands method called!!!");

            throw new Exception("test exception");
            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #15
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommmands()
        {
            //With dep injection
            //return Ok(_reposiory.GetAllCommands());

            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #16
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            // Use Repository in this property
            // A variable to hold results
            var commandItems = _repository.GetAllCommands();

            // Return Success status 200 OK
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _commanderRepo.GetAllCommands();

            if (commandItems.Any())
            {
                return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
            }
            return(NotFound());
        }
Example #18
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            if (commandItems == null)
            {
                return(NotFound());
            }
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            // return'e dikkat:
            // return Ok yazıp içine commandItems listemizi verdik.
            // -> Bu metodumuz Ienumerable<Command> return ediyordu.
            // biz de buna uyarak commandItems'ı return ettik:
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #20
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            _Log.LogInformation("This was called.");
            IEnumerable <Command> commandItems = _Repository.GetAllCommands();

            if (commandItems != null)
            {
                return(Ok(_Mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
            }

            return(NotFound("No able to find command items. Sorry :("));
        }
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            //Ok represents 200 success message. It comes bundled with an optional return param that gives
            //the IEnumerable back to the http request.
            //There are other messeges, like
            //return NotFound() [404]
            //return BadRequest() [400]
            //etc
            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
Example #22
0
        public ActionResult <IEnumerable <Command> > GetAllCommands()
        {
            var commands = _repository.GetAllCommands();

            if (commands.Count() > 0)
            {
                return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commands)));
            }
            else
            {
                return(NotFound());
            }
        }
        new public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            IEnumerable <Command> commandItems = _repository.GetAllCommands();

            List <CommandReadDto> result = new List <CommandReadDto>();

            foreach (var command in commandItems)
            {
                result.Add(new CommandReadDto {
                    Id    = command.Id,
                    HowTo = command.HowTo,
                    Line  = command.Line
                });
            }
            ;

            return(Ok(result));
        }
Example #24
0
        public ActionResult <IEnumerable <Command> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            if (commandItems.ToList().Count() > 0)
            {
                return(Ok(new {
                    data = _mapper.Map <IEnumerable <CommandReadDto> >(commandItems),
                    status = true
                }));
            }
            else
            {
                return(NotFound(new {
                    message = "Não há comandos cadastrados!",
                    status = false
                }));
            }
        }
Example #25
0
        [HttpGet] //GET api/commands
        public ActionResult <IEnumerable <Command> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            return(Ok(commandItems));
        }
Example #26
0
      [HttpGet] public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
      {
          var com = _repo.GetAllCommands();

          return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(com)));
      }
 public ActionResult <IEnumerable <CommandReadDto> > GelAllCommands()
 {
     return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(_repo.GetAllCommands())));
 }
Example #28
0
 public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands() =>
 Ok(_mapper.Map <IEnumerable <CommandReadDto> >(_repository.GetAllCommands()));
Example #29
0
        public ActionResult <IEnumerable <CommandReadDto> > GetAllCommands()
        {
            var commandItems = _commanderRepo.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDto> >(commandItems)));
        }
        public ActionResult <IEnumerable <CommandReadDTO> > GetAllCommands()
        {
            var commandItems = _repository.GetAllCommands();

            return(Ok(_mapper.Map <IEnumerable <CommandReadDTO> >(commandItems)));//ok for http result 200 success
        }